Hi! I’m using ring/compojure to setup a web microservice in clojure. I need CORS to integrate test it, is there any way to setup to :access-control-allow-origin [#"all"]
Wildcard * is not working
@pablore It should be a single regex, I believe. We have :access-control-allow-origin #".*"
and that seems to work.
(I assume you're talking about wrap-cors
?)
yes. For some reason, having #".*"
caused a null pointer exception
Well, #".*"
is what we have so I doubt that was the cause of your NPE.
Specifically, here's the code we have in production:
(let [h (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 #".*")]
...)
(the ...
part returns (fn [req] ...)
and inside that it calls (h req)
and handles the result)