reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
benny 2020-11-15T07:08:16.331800Z

i’m trying to expose my whole API with CORS allowing any origin, but I can’t seem to find a sweet spot on how to accomplish this. I have a structure like so

(def routes-a ["" {:coercion rcs/coercion} ["/foo" {:middleware [custom-mw-stack-1]}]])
(def routes-b ["" {:coercion rcs/coercion} ["/bar" {:middleware [custom-mw-stack-2]}]])
(def app (ring/ring-handler (ring/router [routes-a routes-b])))

2020-11-15T08:56:24.332500Z

@benny Maybe something like that

(def app (ring/ring-handler
          (ring/router
           [routes-a routes-b]
           {:data {:middleware [wrap-cors :access-control-allow-origin [#".*"]
                                          :access-control-allow-methods [:get :put :post :patch :delete]]}})))