Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garmeeh/local-cors-proxy
Simple proxy to bypass CORS issues.
https://github.com/garmeeh/local-cors-proxy
Last synced: about 2 months ago
JSON representation
Simple proxy to bypass CORS issues.
- Host: GitHub
- URL: https://github.com/garmeeh/local-cors-proxy
- Owner: garmeeh
- License: mit
- Created: 2018-03-20T21:01:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-16T19:17:47.000Z (11 months ago)
- Last Synced: 2024-07-18T20:36:55.249Z (2 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 325
- Watchers: 7
- Forks: 77
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Local CORS Proxy
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 disable
```## Getting Started
```
npm install -g local-cors-proxy
```**Simple Example**
API endpoint that we want to request that has CORS issues:
```
https://www.yourdomain.ie/movies/list
```Start Proxy:
```
lcp --proxyUrl https://www.yourdomain.ie
```Then in your client code, new API endpoint:
```
http://localhost:8010/proxy/movies/list
```End 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:
```json
"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 | * |