Fork me on GitHub
#reitit
<
2020-08-14
>
ikitommi04:08:06

@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.

ikitommi04:08:52

["/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}]]

Casey07:08:05

thanks @ikitommi "Only paths that don't have child paths are recognized as separate paths" was the key to my understanding there.

Adam Bergman09:08:11

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.

athomasoriginal13:08:43

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 🙂

Casey13:08:32

@U6GNVEWQG strikes again!

Adam Bergman08:08:21

@U6GNVEWQG thank you very much I will look into your suggestion, much appreciated!

Adam Bergman09:08:30

Thanks in advance for any input! Greetings from Sweden / Adam

Adam Bergman09:08:19

here is some screenshots

tom17:08:22

What is the best way to set up CORS?