Hi, does anybody use the ring-cors
library here? https://github.com/r0man/ring-cors
It is supposed to be an "outer part" middleware right? For example if I have a route, other middlewares, and a ring wrap-defaults
, it should look like this right? :
(-> routes
wrap-middlewares
...
...
(wrap-cors :access-control-allow-origin [#"<http://example.com>"] :access-control-allow-methods [:get :put :post :delete])
(wrap-defaults api-defaults))
@hawari.rahman17 I think you need to swap defaults and cors there.
Yeah, I finally realized that @seancorfield, but sadly the middleware still doesn't work as I expected it to be. It doesn't return any of CORS related headers.
We use it in production and it works just fine.
(ring-cors/wrap-cors handler
:access-control-allow-headers #{"accept"
"authorization"
"content-type"
"origin"}
:access-control-allow-methods [:delete :get
:patch :post :put]
;; 24 hours (in seconds) -- note that only Firefox
;; will honor this; other browsers cap lower!
:access-control-max-age "86400"
:access-control-allow-origin #".*")
That's how we compute our outermost handler.You probably need :access-control-allow-headers
...