I'm developing a shopping web app using Flutter, the app gets products data items from an API which I wrote using ASP .Net Core, for product images I'm using xampp to serve image urls instead of using raw images. I fixed the CORS problem in the data API using the following code:
app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://example:port"));
However, I'm still getting the CORS problem when loading the images from within the app here is what I get after inspecting the debug console:
Access to fetch at 'http://example:port/img/OIP.jpg' from origin 'http://example:port' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled
Here is what I've tried so far:
- Installed a chrome extension that disables CORS, but didn't work.
- Run google chrome with the command:
chrome.exe --user-data-dir="C://chrome-dev-disabled-security" --disable-web-security --disable-site-isolation-trials'
It worked just fine, but this wouldn't be the best solution