如何定义“access-control-allow-origin”的值。对于子域? [英] How to define the value for the "access-control-allow-origin" for sub-domain?
本文介绍了如何定义“access-control-allow-origin”的值。对于子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于部署在服务器中的项目,需要使包含myCompany.com的所有域都可访问。如果使用
For a project deployed in the server, it is needed to make all of domains that contains "myCompany.com" accessible. It works if using
<add name="Access-Control-Allow-Origin" value="*" />
但是如果使用
$ b $则不行b
But not if using
<add name="Access-Control-Allow-Origin" value="myCompany.com" />
如何处理此问题?谢谢。
我尝试了什么:
如何定义子域的Access-Control-Allow-Origin的值?
How can this problem be handled? Thanks.
What I have tried:
How to define the value for the "Access-Control-Allow-Origin" for sub-domain?
推荐答案
使用URL重写的IIS中特定域的启用CORS [ ^ ]
看起来有办法定义一系列URL
Enable CORS for specific domains in IIS using URL Rewrite[^]
Looks like there's ways of defining a range of URLs
我找到了解决这个问题的方法。该方法如下所述:
1)在IIS7管理器中,单击项目。
2)在功能视图中,单击HTTP响应标题的图标。 />
3)对于Access-Control-Allow-Origin,输入类似的值(两者之间有一个空格):
http://myCompany1.com http: //myCompany2.com http://myCompany3.com
备注:它是通过IIS管理器手动完成的,而不是在web.config上完成的。修改后的值不能覆盖到web.config。
I have found the solution for this problem. The approach is described below:
1) In the IIS7 Manager, click the project.
2) From the Feature View, click the icon for HTTP Response Headers.
3) For the "Access-Control-Allow-Origin", enter the values like that (having a single space between):
http://myCompany1.com http://myCompany2.com http://myCompany3.com
Remark: It has been done manually through IIS Manager, NOT on web.config. The revised values CANNOT be overwritten into the web.config.
这篇关于如何定义“access-control-allow-origin”的值。对于子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文