且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

header('Access-Control-Allow-Origin:*');不允许CORS请求

更新时间:2022-06-25 03:53:56

设置标头的代码看起来没有什么问题,但是您可能要检查是否真的设置了标头.使用 curl -i http://yourapp 来检查正在发送的响应标头以对其进行调试.或者,您可以使用Google Chrome浏览器的网络检查器中的网络"标签,也可以使用Firefox的Web开发器工具中的网络"工具.

It doesn't look there is anything wrong with the code that sets the header, but you may want to check if the header is actually being set. Use curl -i http://yourapp to check the response headers being sent to debug it. Alternatively, you can use the network tab in Google Chrome's web inspector, or the Network tool in Firefox's Web Developer tools.