Flutter Web访问URL图像CORS策略
在我试图显示网络映像时,在我的Flutter网络中,我会遇到CORS错误。 从'https://my-network-image-url.jpg'来访问xmlhttprequest'froment'http:// localhost:63785'已被CORS策略阻止:no'Access-Control-allow-Origin'Header存在在请求的资源上。
它在我的Android/iOS移动应用程序中正常工作。
我已经在后端PHP API中提取了同一问题。 当时,添加PHP文件中的标头解决了问题。
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: X-Requested-With,content-type");
我很困惑如何在图像获取请求中添加标头。
对不起,如果我再次问同样的问题。 但是我找不到适当的解决方案。
提前致谢。
In my flutter web when I'm trying to show network image, I'm getting an error of CORS.
Access to XMLHttpRequest at 'https://my-network-image-url.jpg' from origin 'http://localhost:63785' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Its working properly in my Android/iOS Mobile Apps.
I already fetch same issue in my backend php api.
At that time adding headers in php file solve the issue.
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: X-Requested-With,content-type");
I'm confuse how to add header in image get request.
Sorry If I'm asking same question again.
But I could not find proper solution for this.
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从任何其他端点模拟允许所有交叉起源的呼叫,就像我使用以下内容一样,
在呼叫时,您可以使用这样的AA变量,
You can mock the calls from any other endpoint which allows all cross origins like I have used the following,
And while making a call you can use a a variable like this,