http icon indicating copy to clipboard operation
http copied to clipboard

Requests in fluttter web

Open chuck2098 opened this issue 3 years ago • 4 comments

Hi, I have a question. I'm trying to make a http request using this package but i get thie error: image How can I resolve this issue? In local, with emulator device is ok but on web I have this problem.

P.S. I setted also the header "Access-Control-Allow-Origin": "*" Thanks a lot.

chuck2098 avatar Nov 08 '21 15:11 chuck2098

I have this error too.

update: I add headers and solved.

res.headers.add('Access-Control-Allow-Origin', '*'); res.headers.add('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE, HEAD');

ali-1989 avatar Nov 30 '21 08:11 ali-1989

same here cant access my back end using flutter web 2.8.1 , the back end is node js and i applied much methods like cors and xhr2 .. and ading Access-Control-Allow-Origin , Access-Control-Allow-Methods and Access-Control-Allow-Headers but still facing the same problem which XMLHttpRequest error i make it works on local host by adding --disable-web-security to chrome file in the sdk but i used ngrok server and now facing the same error

mustafa-707 avatar Feb 01 '22 10:02 mustafa-707

This problem only occurs when building a web app and hosting from a web server (not localhost). Can the http package somehow wrap this request in a "form" when building the web app so that it avoids the CORS error?

Reference: blocked by CORS policy

Simpler1 avatar Feb 05 '22 22:02 Simpler1

This problem only occurs when building a web app and hosting from a web server (not localhost). Can the http package somehow wrap this request in a "form" when building the web app so that it avoids the CORS error?

Reference: blocked by CORS policy

In my case, I had to create a service to do the request from. It wouldn't work directly from a web page.

Simpler1 avatar Feb 12 '22 19:02 Simpler1

I have the same Problem and can't solve it at the moment. The library example does not work either. (for web)

Nebolon avatar Dec 15 '22 18:12 Nebolon