1.2.0 • Published 3 years ago

@kebab-case/lcp v1.2.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 years ago

Local CORS Proxy

This is a fork of local-cors-proxy - GitHub repo

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 @kebab-case/lcp

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/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:

 "scripts": {
   "proxy": "lcp --proxyUrl https://www.yourdomain.ie"
 }

Options

OptionExampleDefault
--proxyUrlhttps://www.google.ie
--proxyPartialfooproxy
--port80108010
--credentials(no value needed)false
--originhttp://localhost:4200*
1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago