This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-19
Channels
- # announcements (9)
- # babashka (11)
- # beginners (157)
- # calva (10)
- # cider (18)
- # clara (4)
- # clj-kondo (40)
- # cljsrn (8)
- # clojure (29)
- # clojure-europe (11)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-spec (4)
- # clojure-sweden (1)
- # clojure-uk (39)
- # clojurescript (32)
- # conjure (1)
- # core-async (2)
- # cursive (20)
- # datomic (7)
- # duct (9)
- # emacs (1)
- # figwheel-main (1)
- # fulcro (24)
- # helix (1)
- # hoplon (20)
- # hugsql (3)
- # jackdaw (5)
- # jobs-discuss (7)
- # lambdaisland (1)
- # malli (5)
- # music (4)
- # off-topic (54)
- # parinfer (2)
- # pedestal (13)
- # re-frame (12)
- # reagent (22)
- # reitit (9)
- # shadow-cljs (89)
- # spacemacs (2)
- # xtdb (21)
i'm trying to add cors headers through the pedestal config. i set ::http/allowed-origins ["*"]
but the header i get back is blank: Access-Control-Allow-Origin:
and there is no Access-Control-Allow-Methods: header. even if i force "*" for that header, it still gets stripped out. is this something i need a custom interceptor for?
your usage sounds correct to me - I would just double check what the final service config looks like when you start the server. Maybe try copying your service config to a new app template and see if that works also
minus the routes, it looks like this:
{:env :prod,
:io.pedestal.http/not-found-interceptor {:name :neo.common.http.passthrough/passthrough,
:leave #object[neo.common.http.passthrough$fn__36795
0x6ba197f9
"neo.common.http.passthrough$fn__36795@6ba197f9"]},
:io.pedestal.http/routes #{...},
:io.pedestal.http/allowed-origins ["*"],
:io.pedestal.http/type :jetty,
:io.pedestal.http/container-options {:h2c? true, :h2? false, :ssl? false},
:io.pedestal.http/host "0.0.0.0",
:io.pedestal.http/port 8080}
i will try it in a new templateinteresting I'm seeing the headers not show up as well with '*'. digging into the implementation it looks like the origin check is using set membership: https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http/cors.clj#L57
i c. good to know. i opened up a ticket for this https://github.com/pedestal/pedestal/issues/664
that gives me an error unfortunately: #error{:cause "class java.lang.Long cannot be cast to class clojure.lang.IPersistentCollection (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')",
seems like that is caused by something else. Here's a full example: https://github.com/pedestal/pedestal/blob/master/samples/cors/src/cors/server.clj#L27