Flutter Web应用加载图片时遭遇CORS拦截问题求助
Flutter Web应用加载图片时遭遇CORS拦截问题求助
我正在用Flutter开发一款购物Web应用,产品数据是通过我自己用ASP .Net Core编写的API获取的,产品图片则是借助XAMPP来提供URL服务,没有直接使用原始图片文件。
之前我已经解决了数据API的CORS问题,用到的代码如下:
app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://example:port"));
但现在加载图片的时候还是碰到了CORS拦截问题,调试控制台里的报错信息是这样的:
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
目前我已经尝试过的方法:
- 安装了一款禁用CORS的Chrome浏览器扩展,但没有效果。
备注:内容来源于stack exchange,提问作者Mohammad Radwan
相关产品推荐
相关产品推荐

