garmeeh / local-cors-proxy

Simple proxy to bypass CORS issues.
MIT License
328 stars 81 forks source link

Not succeeding, still getting the 'No 'Access-Control-Allow-Origin' header is present on the requested resource.' error #21

Open vinnytwice opened 3 years ago

vinnytwice commented 3 years ago

I'm trying to test endpoints of my Node.js app running on localhost:3000 making requests from my Flutter web app running on localhost:5000 and I get the infamous 'No 'Access-Control-Allow-Origin' header is present on the requested resource.' error. So I'm trying to use local-core-proxy.. In my package.json scripts I added "proxy": "lcp --proxyUrl http://localhost --port 3000" .. and if I got right this should generate localhost:3000/proxy domain which I 'd use for my request as:

final Uri uri = Uri.http('localhost:3000',
        '/proxy/api/products');

But when making the request I still get the error:

Access to XMLHttpRequest at 'http://localhost:3000/proxy/api/products' from origin 'http://localhost:5000' 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.

Am I missing to set something? Many thanks for this package.

vinnytwice commented 3 years ago

Update:

I tried starting the proxy with lcp --proxyUrl https://localhost:3000 --port 3001 in terminal and got :

 Proxy Active 

Proxy Url: https://localhost:3000
Proxy Partial: proxy
PORT: 3001
Credentials: false
Origin: *

To start using the proxy simply replace the proxied part of your url with: http://localhost:3001/proxy

so in my Flutter web app I make the request to String uri = 'http://localhost:3001/proxy/api/products'; but I get net::ERR_CONNECTION_REFUSED error. What am I doing wrong??