From 17e9c6a4bc25bceb219224af1d86606dd12eac68 Mon Sep 17 00:00:00 2001 From: Yann Esposito Date: Wed, 5 Aug 2015 10:03:10 +0200 Subject: [PATCH] added aggressive preflight middleware --- project.clj | 2 +- src/fuck_cors/core.clj | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 3b413f8..4768f27 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject fuck-cors "0.1.5" +(defproject fuck-cors "0.1.6" :description "Fuck CORS and open all to everyone" :url "http://github.com/yogsototh/fuck-cors" :license {:name "MIT" diff --git a/src/fuck_cors/core.clj b/src/fuck_cors/core.clj index eebc754..59b02ad 100644 --- a/src/fuck_cors/core.clj +++ b/src/fuck_cors/core.clj @@ -33,3 +33,14 @@ "Vary" "Accept-Encoding, Origin, Accept-Language"}] (-> (handler request) (update-in [:headers] #(into % headers)))))) + +(defn wrap-preflight + "Add a preflight answer. Will break any OPTIONS handler, beware. + To put AFTER wrap-open-cors" + [handler] + (fn [request] + (if (= (request :request-method) :options) + (into request {:status 200 :body "preflight complete"}) + (handler request)))) + +