繁体   English   中英

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

[英]Wordpress on Azure Error: Blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

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

我试过的

  • 在 azure web 应用程序中启用 CORS
  • 在 web.config 中启用标题配置

资源

Azure Web 应用配置

我的 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>

刚刚找到问题和解决方案问题:Wordpress 的默认嵌入(为 Product Hunt 链接粘贴)不适用于 Product Hunt 嵌入解决方案:我必须自己添加自定义 HTML

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM