CORS与php标头 [英] CORS with php headers
本文介绍了CORS与php标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的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: *");
...
但我仍然得到错误:
请求头字段
X-Requested-With 不允许通过
Access-允许标头
我遗漏了什么?
推荐答案
访问控制允许标头
不允许 *
作为接受的值,请参阅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).
这篇关于CORS与php标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文