开云手机站登录入口成为国际米兰亚洲区官方合作伙伴 - 开云手机站登录入口
3年前 (2023-04-29)
错误消息显示:
没有“ Access-Control-Allow-Origin”标头 同题参见
您已经设置了三个Access-Control-Allow-SOMETHING标头,但都不是Origin。 对照阅读
解决方法
我正在使用Apache httpd服务器托管客户端文件
http://ipaddress:8010/
我的Nodejs服务器正在运行http://ipaddress:8087 延伸阅读
当我发送帖子请求时,它显示以下错误
XMLHttpRequest cannot load http://ipaddress:8010/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ipaddress:8087' is therefore not allowed access.
我的客户端代码是:
$.ajax({
type: "POST",url: "http://ipaddress:8010",data: {name:"xyz"},success: function {
alert("success");
},dataType: "json"
});
我的服务器端是:
response.setHeader('Access-Control-Allow-Methods','GET,POST,OPTIONS,PUT,PATCH,DELETE');
response.setHeader('Access-Control-Allow-Headers','X-Requested-With,content-type');
response.setHeader('Access-Control-Allow-Credentials',true);
允许的选项仍然不起作用,有人可以建议问题出在哪里吗?我在服务器端收到请求。但无法发送任何响应。
提前致谢 :)