WordPress中的访问控制 - 允许原素
我将以下代码添加到我的function.php
中,
function add_cors_http_header(){
header("Access-Control-Allow-Origin: *");
}
add_action('init','add_cors_http_header');
但是当我运行Web应用程序时,会收到以下错误:
XMLHttpRequest error.
I add the following code to my function.php
function add_cors_http_header(){
header("Access-Control-Allow-Origin: *");
}
add_action('init','add_cors_http_header');
But when i run my web application get the following error:
XMLHttpRequest error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要修复Access-Control-Allow-Origin,您必须从
.htaccess
进行操作。这是要添加到该文件的代码以及参考文章,该代码更深入地解释了错误。https://crunchify.com/how-to-fix-access-control-allow-oryigin-origin-sissue-for-your-https-enabled-wordpress-wordpress-site-site-site-and-maxcdn/
To fix Access-Control-Allow-Origin, you have to do it from
.htaccess
. Here is the code to add to that file as well as the reference article, which explains the error in more depth.https://crunchify.com/how-to-fix-access-control-allow-origin-issue-for-your-https-enabled-wordpress-site-and-maxcdn/