From 5ec587e25e9e8e8184584e799cd21c99a362d334 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Tue, 5 Mar 2024 18:00:23 +0100 Subject: [PATCH] Minor update --- README.md | 13 +++++++++++++ src/fuck_cors_app/core.clj | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 105c81c..9ba51fc 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,19 @@ Here is a CORS proxy implemented in very few lines of clojure. lein run ``` +Then in your js code + + +```js +// BEFORE +document.fetch(url) // => FAIL WITH CORS + +// AFTER +document.fetch('http://127.0.0.1:1977/?url=' + encodeURIComponent(url)) // => WORKS +``` + +As simple as that. + ## License Copyright © 2024 Yann Esposito diff --git a/src/fuck_cors_app/core.clj b/src/fuck_cors_app/core.clj index a2863b6..348be72 100644 --- a/src/fuck_cors_app/core.clj +++ b/src/fuck_cors_app/core.clj @@ -1,5 +1,5 @@ (ns fuck-cors-app.core - (:require + (:require [clj-http.client :as client] [ring.adapter.jetty :as jetty] [ring.middleware.params :refer [wrap-params]] @@ -13,10 +13,10 @@ :url url}))) (defn -main - [& args] - (jetty/run-jetty + [& _args] + (jetty/run-jetty (-> handler (wrap-params) - (wrap-open-cors)) + (wrap-open-cors)) {:port 1977 :host "127.0.0.1"}))