Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active June 26, 2024 03:03
Show Gist options
  • Save whamtet/b4b717aae796ab14225bd84107873664 to your computer and use it in GitHub Desktop.
Save whamtet/b4b717aae796ab14225bd84107873664 to your computer and use it in GitHub Desktop.
(def cors-headers
{"Access-Control-Allow-Origin" "*"
"Access-Control-Allow-Methods" "POST, GET, OPTIONS, DELETE"
"Access-Control-Allow-Headers" "*"
"Access-Control-Expose-Headers" "*"})
(defn wrap-cors [handler]
(fn [req]
(if (-> req :request-method (= :options))
{:status 200
:headers cors-headers
:body ""}
(-> req
handler
(update :headers merge cors-headers)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment