Hello everyone! I have a question here regarding catch-all routes and if/how they are supported in reitit
Say I have a full stack application where clojure serves a frontend SPA, the server exposes a /api routes group
I would like to have all other routes that don’t start with /api to serve the static page+javascript that composes the SPA frontend, currently I have a route like /*path that should catch all of the other requests not directed to the api routes
It turns out that I tried multiple ways to do this but reitit fails with conflicting route errors, the ones documented here https://cljdoc.org/d/metosin/reitit/0.9.2/doc/basics/route-conflicts
Is there a way to enable a behavior like this? am I missing something?
The order is significant, our catch-all is the last route definition (directs all other urls to api docs, could be your spa) and we resolve all conflicts as follows
["/*"
{:get
{:no-doc true
:summary "API documentation"
:handler (fn [_request]
{:status 301
:headers {"Location" "/api-docs/index.html"}})}}]]
;; Route options
{:conflicts (constantly nil) ;; allow the catch-all path for SPA
... i also explored this earlier: https://clojurians.slack.com/archives/C7YF1SBT3/p1746733018619409
Oh wow @thmorriss this is exactly what I was looking for!!
For now I did a workaround where the not-found handler renders the SPA index file in case the request doesn’t start with /api
The solution you shared seems better and less hacky, thank you!!!