简体   繁体   English

Flutter - XMLHttpRequest 已被 CORS 政策阻止

[英]Flutter - XMLHttpRequest has been bloked by CORS policy

I'm working on Flutter and in my php API, I put these headers :我正在研究 Flutter,在我的 php API 中,我放置了这些标头:

header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header("Access-Control-Allow-Headers: X-Requested-With");

but I still have the anserw :但我仍然有答案:

" Access to XMLHttpRequest at 'http://localhost/spring_box/api.php' from origin 'http://localhost:52502' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' " Access to XMLHttpRequest at 'http://localhost/spring_box/api.php' from origin 'http://localhost:52502' has been blocked by CORS policy: The 'Access-Control-Allow-Origin'

Can you help me to solve my problem please?你能帮我解决我的问题吗?

Follow below steps按照以下步骤操作

1- Go to flutter\\bin\\cache and remove a file named: flutter_tools.stamp 1- 转到 flutter\\bin\\cache 并删除名为:flutter_tools.stamp 的文件

2- Go to flutter\\packages\\flutter_tools\\lib\\src\\web and open the file chrome.dart in Text editor. 2- 转到 flutter\\packages\\flutter_tools\\lib\\src\\web 并在文本编辑器中打开文件 chrome.dart。

3- Search & find '--disable-extensions' 3- 搜索并找到“--disable-extensions”

4- Add '--disable-web-security' 4- 添加'--disable-web-security'

5- Save. 5-保存。 and Try Now立即尝试

Happy Coding.快乐编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 从源访问 XMLHttpRequest 已被 CORS 策略阻止 - Laravel Access to XMLHttpRequest at from origin has been blocked by CORS policy 来自'http:// localhost / api from origin'http:// localhost:8000'的XMLHttpRequest访问已被CORS策略阻止 - Access to XMLHttpRequest at 'http://localhost/api from origin 'http://localhost:8000' has been blocked by CORS policy XAMPP 服务器已被 CORS 策略阻止: - XAMPP Server has been blocked by CORS policy: ReactJS-PHP GET请求已被CORS策略阻止 - ReactJS - PHP GET Request has been blocked by CORS policy 已被 CORS 政策阻止:无“访问控制允许来源” - has been blocked by CORS policy: No 'Access-Control-Allow-Origin' 获取 wp_mail 已被 CORS 策略阻止 - Fetching wp_mail has been blocked by CORS policy 如何解决问题 Axios:已被 CORS 政策阻止: - how to fix the problem Axios : has been blocked by CORS policy: 通过axios requert调用php文件已被VUE CLI 3中的CORS策略阻止 - Call php file via axios requert has been blocked by CORS policy in VUE CLI 3 访问 abcd.com 上的字体已被 CORS 政策阻止:没有“访问控制允许来源” - Access to Font at abcd.com has been blocked by CORS policy: No 'Access-Control-Allow-Origin' PHP-CORS策略已阻止对字体的访问:没有“ Access-Control-Allow-Origin”标头 - PHP - Access to Font has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM