猿问

https协议下,post请求跨域,get请求没跨域;

https协议下,post请求跨域,get请求没跨域,http协议没问题;

相关代码

https://img1.mukewang.com/5c8f46f60001404b07090172.jpg

https://img3.mukewang.com/5c8f46f70001c50505310135.jpg

https://img4.mukewang.com/5c8f46f80001686006780045.jpg

https://img1.mukewang.com/5c8f46f900015b3604740585.jpg

慕的地8271018
浏览 3913回答 3
3回答

SMILET

还是跨域的问题没有解决。 前端需要允许跨域,加入xhrFields,jQuery的话,大概这样: $.ajax({ type: "POST", xhrFields:{ withCredentials:true }, success: function(){ } }); 后端加入header header("Access-Control-Allow-Credentials", "true"); header("Access-Control-Allow-Origin", "允许跨域的地址,如果全部允许写*");

慕工程0101907

// 使用通配符 * ,表示当前服务端 返回的信息允许所有源访问,也可指定可信任的域名来接收响应信息
 header("Access-Control-Allow-Origin: http://localhost:3000"); header("Access-control-Allow-Origin:*"); // 响应头设置为ajax提交
 header("Access-Control-Allow-Headers:X-Requested-With"); // 允许携带 用户认证凭据(也就是允许客户端发送的请求携带Cookie)
 header("Access-Control-Allow-Credentials:true"); 写到方法内部
随时随地看视频慕课网APP
我要回答