黄聪:No 'Access-Control-Allow-Origin' header is present on the requested resource解决办法

时间:2023-03-10 00:59:57
黄聪:No 'Access-Control-Allow-Origin' header is present on the requested resource解决办法

在.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>