首页 > 技术文章 > 黄聪:No 'Access-Control-Allow-Origin' header is present on the requested resource解决办法

huangcong 2016-04-05 16:27 原文

.htaccess文件里面添加下面代码:

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

web.config文件设置:

<system.webServer>
  ...

    <httpProtocol>
        <customHeaders>
            <!-- Enable Cross Domain AJAX calls -->
            <remove name="Access-Control-Allow-Origin" />
            <add name="Access-Control-Allow-Origin" value="*" />
        </customHeaders>
    </httpProtocol>
</system.webServer>

 

推荐阅读