我想在 JavaScript 中使用 Azure 服务总线 REST API。不幸的是,我遇到了跨源问题,因为我的服务总线命名空间与我的站点不在同一域中。
我知道您可以使用许多 Azure 服务启用 CORS,但我在 Azure 文档或其他地方找不到任何资源告诉我如何为服务总线执行此操作。
有谁知道是否可以以及如何做到这一点?
我通过使用以下内容创建一个单独的 Web 应用程序解决了这个问题Web.config
这只是一个简单的代理。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Proxy" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{CACHE_URL}" pattern=".*" />
</conditions>
<action type="Rewrite" url="https://mynamespace.servicebus.windows.net/{R:0}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Expose-Headers" value="BrokerProperties" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)