local-cors-proxy-remixed v1.2.0
Local CORS Proxy
(This is a fork of the original repository at https://github.com/garmeeh/local-cors-proxy. Basically adds support for skipping SSL certificate validation - a usecase important when trying to proxy URL's with self-signed certificates).
(To install this new updated fork, just run npm install local-cors-proxy-remixed or npx local-cors-proxy-remixed).
Simple proxy to bypass CORS issues. This was built as a local dev only solution to enable prototyping against existing APIs without having to worry about CORS.
This module was built to solve the issue of getting this error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disableGetting Started
npm install -g local-cors-proxy-remixedSimple Example
API endpoint that we want to request that has CORS issues:
https://www.yourdomain.ie/movies/listStart Proxy:
lcp --proxyUrl https://www.yourdomain.ieThen in your client code, new API endpoint:
http://localhost:8010/proxy/movies/listEnd result will be a request to https://www.yourdomain.ie/movies/list without the CORS issues!
Alternatively you can install the package locally and add a script to your project:
"scripts": {
"proxy": "lcp --proxyUrl https://www.yourdomain.ie"
}Options
| Option | Example | Default |
|---|---|---|
| --proxyUrl | https://www.google.ie | |
| --proxyPartial | foo | proxy |
| --port | 8010 | 8010 |
| --credentials | (no value needed) | false |
| --origin | http://localhost:4200 | * |
| --rejectUnauthorized | 0 (disabled) / 1 (enabled) | 1 |