admin管理员组文章数量:1405316
I'm trying to add CORS headers for specific domains using the following rule:
<rewrite>
<outboundRules>
<rule name="AddCrossDomainHeader">
<match serverVariable="RESPONSE_Access_Control_Allow_Origin" pattern=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{CAPTURED_ORIGIN}" pattern="^(https:\/\/(sitename-(dev|qa|uat)\.domain2\|utech-sandbox\.domain\|subdomain\.domain\|uat\.program\))$|^(https:\/\/localhost:7024)$" />
</conditions>
<action type="Rewrite" value="{C:0}" />
</rule>
</rewrite>
</outboundRules>
However, I am still encountering CORS errors when making requests from the frontend. The error message I get is something like:
Access to XMLHttpRequest at '...' from origin '...' has been blocked by CORS policy
What I've Observed:
Locally: This works as expected when I run a demo application locally. The CORS header is added correctly.
Deployed: When I deploy the same configuration to my server, the CORS header (Access-Control-Allow-Origin) is not being set in the response, leading to the CORS error.
What I Have Tried: Access-Control-Allow-Methods and Access-Control-Allow-Headers headers are configured correctly. I can see the Access-Control-Allow-Origin header isn't appearing in the response from the deployed server. The CAPTURED_ORIGIN value seems to be correctly identified during testing, but the rewrite rule doesn't seem to apply on the deployed server.
Questions: Is there something specific in the IIS configuration that I might have missed in the deployed environment? Are there any other CORS-related headers I should consider that might impact the origin header? Could there be issues related to the server's network setup or permissions that might prevent the rewrite rule from working correctly on deployment?
Any help or pointers would be greatly appreciated!
本文标签: net 48CORS Error Despite Adding Custom AddCrossDomainHeader Rule in IISStack Overflow
版权声明:本文标题:.net 4.8 - CORS Error Despite Adding Custom AddCrossDomainHeader Rule in IIS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744904868a2631558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论