You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 14:55:30