我在 Mac OS 设备上运行我的项目,并且想从另一台笔记本电脑进行访问。
第一个设备也从服务器获取所有响应:
http://192.168.1.101:3000/ http://192.168.1.101:3000/
但另一台笔记本电脑我收到此错误消息:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.shadyab.com/api/Api/coupons. (Reason: missing token ‘access-control-allow-origin’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': '*'},
body: JSON.stringify(formData)
};
Add
headers: {'Access-Control-Allow-Origin': '*'}
到您从中获取 API 的服务器
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)