Fork me on GitHub
#reitit
<
2021-07-13
>
jjttjj19:07:05

With this router

(rring/ring-handler router
                  (rring/routes
                    (rring/create-resource-handler {:root "shadow-output" :path "/"})
                    (rring/create-file-handler {:root "public" :path "/"})
                    (rring/create-default-handler))
                  {:middleware [[(fn [handler]
                                   (ring-dflt/wrap-defaults handler ring-dflt/site-defaults))]]})
I'm getting a weird figwheel index page served. I'm not using figwheel at all. If i remove the middleware the correct index is served from (from the file handler, it's in public). But I need to use the middleware. Any easy fix for this?

jjttjj20:07:16

Ok figured this out, it's because the site-defaults map includes settings to serve public resources, which was in my resources from another project

jjttjj20:07:27

Also, and this is related, any tips on using reitit with sente would be greatly appreciated 🙂 I'm aware of https://github.com/metosin/reitit/issues/205 but can't for the life of me get ring wrap-defaults to work which is needed for the csrf token that sente uses

jjttjj21:07:00

Got it!

(rring/ring-handler router
                  (rring/routes
                    (rring/create-file-handler {:root "public" :path "/"})
                    (rring/create-resource-handler {:root "shadow-output" :path "/"})
                    (rring/create-default-handler))
                  {:middleware [[(fn [routes]
                                   (ring-dflt/wrap-defaults routes
                                     (dissoc ring-dflt/site-defaults :static)))]]})
is what worked for me as far as ring's wrap-defaults goes