Mostafa Efafi
Mostafa Efafi

Reputation: 785

flutter web application does not send server requests

I made a build of the web version of the application with the following command:

flutter build web --web-renderer html

But when I ran the output with python -m http.server 8000 command in my local system, none of the program requests were sent And I got the following error in Firefox console :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://MY_SERVER_URL. (Reason: CORS request did not succeed). Status code: (null). Uncaught Error: NoSuchMethodError: j is undefined

Please help me to run the web application on localhost.

Upvotes: 1

Views: 738

Answers (1)

m3h
m3h

Reputation: 94

First, I suggest you read about CORS, which I gave you the link

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

But the easiest solution is to run the flutter webapp locally: Download the CORS plugin and install it in your browser (also available for Firefox) Extension link in Chrome browser:

https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf

When you want to run your program, click on it and activate it This will not check CORS for your web, and solved your problem

But one point in your error is not mentioned which part is blocked, usually the headers are blocked, so after installing the plugin, enter the plugin settings and check it. Access-Control-Allow-Headers check it to solve your problem, if not solved , please send me a more complete error.

Upvotes: 1

Related Questions