Last active
June 26, 2024 03:03
-
-
Save whamtet/b4b717aae796ab14225bd84107873664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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