Minor update
This commit is contained in:
parent
d33d4b3b35
commit
5ec587e25e
13
README.md
13
README.md
|
@ -11,6 +11,19 @@ Here is a CORS proxy implemented in very few lines of clojure.
|
||||||
lein run
|
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
|
## License
|
||||||
|
|
||||||
Copyright © 2024 Yann Esposito
|
Copyright © 2024 Yann Esposito
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(ns fuck-cors-app.core
|
(ns fuck-cors-app.core
|
||||||
(:require
|
(:require
|
||||||
[clj-http.client :as client]
|
[clj-http.client :as client]
|
||||||
[ring.adapter.jetty :as jetty]
|
[ring.adapter.jetty :as jetty]
|
||||||
[ring.middleware.params :refer [wrap-params]]
|
[ring.middleware.params :refer [wrap-params]]
|
||||||
|
@ -13,10 +13,10 @@
|
||||||
:url url})))
|
:url url})))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& args]
|
[& _args]
|
||||||
(jetty/run-jetty
|
(jetty/run-jetty
|
||||||
(-> handler
|
(-> handler
|
||||||
(wrap-params)
|
(wrap-params)
|
||||||
(wrap-open-cors))
|
(wrap-open-cors))
|
||||||
{:port 1977
|
{:port 1977
|
||||||
:host "127.0.0.1"}))
|
:host "127.0.0.1"}))
|
||||||
|
|
Loading…
Reference in a new issue