cors-backdoor
v1.0.6
Published
A simple proxy server built using express to bypass cors restrictions during development
Downloads
8,826
Maintainers
Readme
A temporary workaround for common CORS errors like:
Access to fetch at 'http://api.example.com/posts' from origin 'http://localhost:8082' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Access to fetch at 'http://api.example.com/posts' from origin 'http://localhost:8082' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
Installation
Install as a global module (recommended)
npm install -g cors-backdoor
Install as a dev dependency
npm install -D cors-backdoor
Quick Start
cors-backdoor --target http://api.example.com
This will start a local proxy running on the port 1234
for the target http://api.example.com
. The client will have to
be reconfigured to make requests which looked like http://api.example.com/posts
to http://localhost:1234/posts
instead
Documentation
CLI API, Advanced configuration and more on the docs page https://drishtilabs.github.io/cors-backdoor