Fork me on GitHub
#ring
<
2018-02-23
>
hawari09:02:27

Hi, does anybody use the ring-cors library here? https://github.com/r0man/ring-cors

hawari09:02:00

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 [#""] :access-control-allow-methods [:get :put :post :delete])
    (wrap-defaults api-defaults))

seancorfield16:02:47

@hawari.rahman17 I think you need to swap defaults and cors there.

hawari23:02:26

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.

seancorfield23:02:21

We use it in production and it works just fine.

seancorfield23:02:05

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

seancorfield23:02:26

You probably need :access-control-allow-headers...