Call any API in Flutter web they all will give XMLHttpRequest an error. The only way to deal with it is by flagging the security of Chrome flutter run -d chrome --web-browser-flag "--disable-web-security" but this is not the solution and it doesn't work in release.
Adding CORS to headers also doesn't work. The same API has to be called by some middleware API then it works but upon directly calling the API to Flutter Web it always gives XMLHttpRequest an error.
Even after building Flutter Web and hosting it somewhere, XMLHttpRequest error doesn't go away.
Expected results:
Api's request should be successful.
Actual results:
Access to XMLHttpRequest at 'api url here' from origin 'http://localhost:49303' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Comments
Post a Comment