Azure上的Wordpress错误:被CORS策略阻止:所请求的资源上不存在“ Access-Control-Allow-Origin”标头

时间:2020-02-08 16:03:05

标签: wordpress azure cors

我在此页面1上遇到此错误(https://anthonytd.com/171/2020-jan-products-roundup/

我尝试过的

  • 在Azure Web应用程序中启用了CORS
  • 在web.config中启用了标头配置

资源

Azure Web app config

我的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
            <add name="Access-Control-Allow-Headers" value="Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" />
            <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
            <add name="Access-Control-Allow-Credentials" value="true" />
        </customHeaders>
    </httpProtocol>
    <rewrite>
      <rules>
            <rule name="WordPress: http://anthonytd.azurewebsites.net" patternSyntax="Wildcard">
                <match url="*"/>
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                    </conditions>
                <action type="Rewrite" url="index.php"/>
            </rule>
            <rule name="Redirect requests from default Azure websites domain" stopProcessing="true">
                <match url="(.*)" /> 
                <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}" pattern="^anthonytd\.azurewebsites\.net$" />
                <add input="{HTTP_HOST}" pattern="^www\.anthonytd\.com$" />
                </conditions>
                <action type="Redirect" url="https://anthonytd.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>

  </system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:0)

刚刚找到问题和解决方案 问题:Wordpress的默认嵌入(粘贴到“产品搜索”链接中)不适用于“产品搜索”嵌入 解决方案:我必须自己添加自定义HTML