Apache 将 Access-Control-Allow-Origin 从 http 设置为 https

Apache set Access-Control-Allow-Origin from http to https

我有基本的 bitnami wordpress 安装。我按照他们的指南设置了 https 和自动 http 到 https 重定向。

然而,当我尝试加载外部脚本时,出现以下错误:

Failed to load https://external-script.com/: The 'Access-Control-Allow-Origin' 
header has a value 'http://my-site.io' that is not equal to the supplied origin. 
Origin 'https://my-site.io' is therefore not allowed access.

我应该编辑哪个文件,应该添加什么? 谢谢

这里是 Bitnami 工程师。

您需要在 WordPress 中启用 CORS。为此,您需要在 installdir/apps/wordpress/conf/httpd-app.conf 文件

中设置此行
...
<Directory /opt/bitnami/apps/wordpress/htdocs/>
...
Header set Access-Control-Allow-Origin "*"
...
</Directory>

之后,您将需要重新启动 Apache 服务器以加载此配置。

installdir/ctlscript.sh restart apache

您还将找到启用 CORS 的不同方法,方法如下 our documentation guide

此致, 若塔