This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-12
Channels
- # announcements (2)
- # bangalore-clj (4)
- # beginners (97)
- # calva (57)
- # cider (24)
- # clj-kondo (1)
- # cljdoc (4)
- # cljs-dev (8)
- # cljsrn (6)
- # clojure (27)
- # clojure-berlin (7)
- # clojure-dev (95)
- # clojure-europe (16)
- # clojure-italy (15)
- # clojure-losangeles (9)
- # clojure-nl (8)
- # clojure-spec (10)
- # clojure-uk (29)
- # clojurescript (25)
- # clojutre (2)
- # clr (6)
- # cursive (33)
- # datomic (20)
- # dirac (1)
- # duct (9)
- # fulcro (2)
- # graalvm (18)
- # jobs (5)
- # jobs-discuss (19)
- # nrepl (4)
- # nyc (1)
- # off-topic (18)
- # pathom (15)
- # re-frame (22)
- # reagent (4)
- # reitit (1)
- # rewrite-clj (9)
- # spacemacs (2)
- # xtdb (12)
I'm trying to add CORS ring middleware into my duct app (routing using ataraxy). My duct config looks something like this:
{:duct.core/project-ns my
:duct.router/ataraxy {:routes ^:cors
{:options [:my.handler/empty-handler]
[:get "/ping"] [:my.handler/ping]}
:middleware {:cors #ig/ref :my.middleware.cors/cors}}
:my.handler/empty-handler {}
:my.handler/ping {}}
My question is: how do I avoid needing that empty-handler
for the pre-flight request?
i.e. how do I apply the answer to this issue using duct? https://github.com/weavejester/ataraxy/issues/19.It's probably not really relevant but the ring middleware I'm using is: https://github.com/r0man/ring-cors
I can't help but feel that I'm missing a trick here. Should the cors middleware be applied at a higher level than where I have it on the routes? It is also having the side effect that my route handlers have to return vanilla ring response maps (instead of ataraxy response vectors)
I have a :handlers
key next to :routes
and :middleware
, maybe try that?
or try this:
:duct.handler/root
{:router #ig/ref :duct.router/ataraxy
:middleware [ #ig/ref :vocal.middleware/cors]}
That was probably what I meant in that issue. Sorry I’m just looking at this quickly and I haven’t been in that project in a while.Thanks @U1UEABW4W I'll take a look when I'm in front of my code later.