如何在Safari中允许跨域请求?

时间:2022-08-23 10:29:36

I have webapp I run from localhost (because of debugging) and it makes cross-domain AJAX requests. I can easily set flag for Chrome "--disable-web-security" and the webapp works as expected in Chrome. But I need to do this for Safari on Windows as well. Is there some similar flag or can I set this in Preferences somewhere ?

我有从localhost运行的webapp(因为调试),它发出跨域AJAX请求。我可以很容易地为Chrome设置标记“-去功能化-网络安全”,并且webapp在Chrome中可以像预期的那样工作。但是我也需要在Windows上运行Safari。是否有类似的标志或者我可以在偏好设置中设置它?

Thanks for help.

谢谢你的帮助。

1 个解决方案

#1


3  

Solution is to set a header Access-Control-Allow-Origin: * on the server.

解决方案是在服务器上设置一个头访问控制允许来源:*。

In PHP it's easy like this:

在PHP中,这很简单:

header("Access-Control-Allow-Origin: *");

Credit for the answer goes to Brain2000, thanks for suggesting a link in your comment.

感谢您在您的评论中提供的链接。

#1


3  

Solution is to set a header Access-Control-Allow-Origin: * on the server.

解决方案是在服务器上设置一个头访问控制允许来源:*。

In PHP it's easy like this:

在PHP中,这很简单:

header("Access-Control-Allow-Origin: *");

Credit for the answer goes to Brain2000, thanks for suggesting a link in your comment.

感谢您在您的评论中提供的链接。