This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-18
Channels
- # architecture (25)
- # beginners (57)
- # boot (3)
- # cider (38)
- # clara (6)
- # cljsrn (6)
- # clojure (54)
- # clojure-china (4)
- # clojure-greece (1)
- # clojure-italy (3)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (68)
- # clojure-uk (46)
- # clojurescript (73)
- # community-development (2)
- # core-async (7)
- # cursive (17)
- # datomic (143)
- # duct (2)
- # emacs (12)
- # events (5)
- # figwheel (3)
- # fulcro (15)
- # hoplon (19)
- # jobs (12)
- # jobs-discuss (85)
- # nginx (3)
- # off-topic (111)
- # onyx (7)
- # other-languages (1)
- # re-frame (30)
- # reagent (19)
- # remote-jobs (1)
- # ring (7)
- # rum (1)
- # shadow-cljs (18)
- # spacemacs (4)
- # specter (4)
- # sql (24)
- # test-check (1)
- # unrepl (10)
- # vim (6)
- # yada (1)
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
?)
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)