auto-cors
A proxy to automatically add CORS headers, supports:
- Simple requests with
Access-Control-Allow-Origin: "*"
- preflight requests for non-simple requests.
- POST/PUT requests with body.
- CORS requests with credentials included.
There's an auto-cors
service deployed at cors.harttle.com. Both HTTP and HTTPS are supported:
Set Cookie
when forward, cookie
is not allowed to be set for fetch
fetch("https://cors.harttle.com/https://example.com", {
headers: {
"AutoCORS-Cookie": "XXX"
}
})
Will set a "Cookie: XXX" header when request is forwarded.
Deploy your server
Install node and npm
, then run
npx auto-cors
Use AUTO_CORS_PORT
(defaults to 8080
) to set a different port, for example:
AUTO_CORS_PORT=8080 npx auto-cors
Visit http://localhost:8080/https://example.com in your browser.
Systemd
Here's a systemd script for auto-cors:
https://gist.github.com/harttle/a801084f42b9ee1a2aa6bf5c191b9ad9