Fork me on GitHub
#reitit
<
2020-09-13
>
vmarcinko19:09:55

Hello. Just getting acquainted with reitit, and am wondering what is the state of CORS support in Reitit... Found on the web problems with ring CORS middleware, so are there some news on this, and if there's still no official Reitit support for this, how do people handling it in the mean time?

dharrigan19:09:45

I roll my own, i.e.,

dharrigan19:09:00

(ring/router
   [["/api"
     ["/ping" {:get {:handler pong}}]
     ["/foo"
      ["" {:options {:handler cors-handler}
...
...

dharrigan19:09:17

(def cors {"Access-Control-Allow-Origin" "*"
           "Access-Control-Allow-Headers" "Origin, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Content-Type, *"})

dharrigan19:09:27

(defn cors-handler
  [_]
  {:headers cors :status ok})

dharrigan19:09:30

works for me 🙂

dharrigan19:09:54

others may have different approaches 🙂

dharrigan19:09:17

np. It's super simple to do it yourself 🙂

dharrigan19:09:19

ttfn! 🙂