ring

hawari 2018-02-23T09:33:27.000287Z

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

hawari 2018-02-23T09:37:00.000211Z

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))

seancorfield 2018-02-23T16:53:47.000371Z

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

hawari 2018-02-23T23:01:26.000229Z

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.

seancorfield 2018-02-23T23:03:21.000392Z

We use it in production and it works just fine.

seancorfield 2018-02-23T23:09:05.000206Z

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

seancorfield 2018-02-23T23:11:26.000152Z

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