带有PHP标头的跨域请求标头(CORS) [英] Cross-Origin Request Headers(CORS) with PHP headers
本文介绍了带有PHP标头的跨域请求标头(CORS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的PHP脚本,正在尝试跨域CORS请求:
I have a simple PHP script that I am attempting a cross-domain CORS request:
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
...
但是我仍然收到错误消息:
Yet I still get the error:
Access-Control-Allow-Headers
我想念什么吗?
推荐答案
Access-Control-Allow-Headers
不允许*
作为接受的值,请参见Mozilla文档
Access-Control-Allow-Headers
does not allow *
as accepted value, see the Mozilla Documentation here.
您应该发送可接受的标题(而不是星号)(如错误提示所述,首先发送X-Requested-With
).
Instead of the asterisk, you should send the accepted headers (first X-Requested-With
as the error says).
这篇关于带有PHP标头的跨域请求标头(CORS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文