@ramblurr when a router is created, all nested paths are concatenated and route data is accumulated. Having an ""
as path somewhere adds nothing visible in the (string) concatenation, so you can have as many of those. Only paths that don't have child paths are recognized as separate paths (before the or gets merged), so you might need to add a empty ""
into the end of the path so it doesn't have child routes.
["/api"
["/admin" {:middleware [::admin]}
["" ::admin]
["/db" ::db]]
["/ping" ::ping]]
=>
[["/api/admin" {:middleware [::admin], :name ::admin}]
["/api/admin/db" {:middleware [::admin], :name ::db}]
["/api/ping" {:name ::ping}]]
thanks @ikitommi "Only paths that don't have child paths are recognized as separate paths" was the key to my understanding there.
Hi everybody!
I would be super grateful if somebody could point me in the right direction, I have searched the web but am unable to make it work. I am trying to create an little web app using reitit on the backend. During development I am using shadow-cljs for running the FE on port 3000, and http-kit/ring/reitit on port 4000
Later I want to deploy my little app by compiling it into an uberjar, and serve the FE (index.html, css and (cl)js) “though” the backend (perhaps not the correct terminology). I am thinking that the route “/” will serve my index.html. Perhaps I want some api-endpoints in the backend for instance “/api/getcandy” or something like that.
Now to my routing-issue. My index.html lies under resources/public/index.html
but when I go to the “home” route localhost:4000
or localhost/index.html
i get 404. I have no clue how to debug this, I am thinking that I should be able to connect to running backend-repl and see stacktraces flying around but I dont know how.
@tkjone thank you very much I will look into your suggestion, much appreciated!
Thanks in advance for any input! Greetings from Sweden / Adam
here is some screenshots
Just read over this quickly and looked at your code image. Here is how I made all the front end routes hitting “/*” work: https://gist.github.com/athomasoriginal/14c6cfa1500bc1ab1a90a98b9d7217a0 Let me know if that helps 🙂
@tkjone strikes again!
What is the best way to set up CORS?