Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vinnytwice opened this issue Jun 13, 2021 · 1 comment

Comments

@vinnytwice
Copy link

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
Copy link
Author

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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant