1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 30 Jun 2022 11:12:55 -0400
Subject: Fix endless redirects with Compojure > 1.5.0
Compojure tries all routes in order until a non-nil response is received. PDB
specifies "/" as the first route which should always match, but didn't in
earlier versions, probably due to #125[1]. With Compojure 1.6, "/" will match
any route, leading to endless redirects.
Fix this by moving "/" to the end of the list.
Last-Update: 2022-06-30
Forwarded: no
---
src/puppetlabs/puppetdb/pdb_routing.clj | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/puppetlabs/puppetdb/pdb_routing.clj b/src/puppetlabs/puppetdb/pdb_routing.clj
index d68667c..e0c1124 100644
--- a/src/puppetlabs/puppetdb/pdb_routing.clj
+++ b/src/puppetlabs/puppetdb/pdb_routing.clj
@@ -38,12 +38,7 @@
(partition
2
;; The remaining get-shared-globals args are for wrap-with-globals.
- ["/" (fn [req]
- (->> req
- rreq/request-url
- (format "%s/dashboard/index.html")
- rr/redirect))
- "/dashboard" (dashboard/build-app dashboard/default-meter-defs)
+ ["/dashboard" (dashboard/build-app dashboard/default-meter-defs)
"/meta" (meta/build-app db-cfg defaulted-config)
"/cmd" (cmd/command-app get-shared-globals
enqueue-command-fn
@@ -54,7 +49,12 @@
query-fn
db-cfg
clean-fn
- delete-node-fn)]))))
+ delete-node-fn)
+ "/" (fn [req]
+ (->> req
+ rreq/request-url
+ (format "%s/dashboard/index.html")
+ rr/redirect))]))))
(defn pdb-app [root maint-mode-fn app-routes]
(compojure/context root []
|