Closed ieugen closed 2 years ago
I managed to fix this by rendering the same route at both "" and "/" .
Should the examples be updated? Should we mount the htmx example by default to anther route ?!
(defn ui-routes [_opts]
[["" {:get home}]
["/" {:get home}]
["/clicked" {:post clicked}]])
I think the proper way would be to do
(defn ui-routes [_opts]
[""
["/" {:get home}]
["/clicked" {:post clicked}]])
Thanks, should I update the examples (modules)?
Yeah, that'd be a good idea if you have time. :)
Well, your solution does not seem to work. I get the same behavior as in normal case.
Oh sorry, misread the original question. Here's what the official docs for Reitit suggest here https://github.com/metosin/reitit/blob/master/doc/ring/slash_handler.md
The answer is in the docs you sent. To have good errors, they recommend composing it with default handler:
handler.clj
(ring/routes
;; Handle trailing slahs in routes
;; https://github.com/metosin/reitit/blob/master/doc/ring/slash_handler.md
(ring/redirect-trailing-slash-handler)
(ring/create-default-handler
{:not-found
(constantly {:status 404, :body "Page not found"})
:method-not-allowed
(constantly {:status 405, :body "Not allowed"})
:not-acceptable
(constantly {:status 406, :body "Not acceptable"})}))
Hi,
I can't access routes mounted to "/example-route" . It turns address bar blank and page does not work in Firefox. I must use "/example-route/" .
I believe this is because routes, by default only listen to "/" and not to "" as well. This might be a non issue for more seasoned devs, but to me it is.
How I got here: I have a new porject started with html and htmx modules. I got an error because both are trying to use the same route "/" so I decided to move htmx to "/htmx-clicked" . I changed the entry to:
Opened
http://localhost:3000/htmx-clicked
and the address bar went blank and web page is not responding. I can't even right click inside of it in FF.