This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-19
Channels
- # ai (4)
- # announcements (1)
- # babashka (6)
- # beginners (31)
- # biff (1)
- # calva (11)
- # cider (9)
- # clerk (6)
- # clojure (40)
- # clojure-europe (49)
- # clojure-nl (1)
- # clojure-norway (30)
- # clojurescript (17)
- # conjure (1)
- # core-async (2)
- # datalevin (28)
- # emacs (1)
- # events (4)
- # fulcro (7)
- # gratitude (1)
- # guix (4)
- # hyperfiddle (19)
- # juxt (10)
- # luminus (4)
- # malli (4)
- # missionary (11)
- # nbb (3)
- # pedestal (7)
- # reagent (27)
- # reitit (2)
- # releases (1)
- # shadow-cljs (32)
- # tools-deps (6)
- # xtdb (5)
I’m trying to use the CORS interceptor that comes out of the box with Pedestal, but I can’t figure out what I’m doing wrong. I am using the following service map.
{::http/routes routes
::http/type :jetty
::http/port 8080
::http/join? false
::http/allowed-origins [""]}
My route tree looks as follows:
(def routes
(route/expand-routes #{["/hello" :get hello :route-name :routes/get-hello]
["/hello" :head hello :route-name :routes/head-hello]}))
Then when try sending OPTIONS /hello
, I get a 404 response from the server.add this:
::http/allowed-origins {:allowed-origins (fn [origin]
(let [allowed (contains? #{""} origin)]
(log/info :origin origin :allowed allowed)
allowed))}
Will help you to debug.
maybe your allowed-origins
is not working (aka no logs at all). this is because you are not using default-interceptors or something like
maybe you are using the wrong origin
nameYour suggestion works, it looks like I misread the docstring or it’s become outdated
checkout this function https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http/cors.clj#L49-L58