如何在 Azure 存储 Blob 上启用 CORS

How do I enable CORS on Azure Storage Blob

我正在尝试使用此 article. It needs to be CORS enabled. I have tested it using test-cors.org 使用 Azure 存储 blob 自定义 Azure B2C 上的 UI 页面,我知道它不是,但我不知道如何设置它

Ther article uses https://wingtiptoysb2c.blob.core.windows.net/b2c/wingtip/selfasserted.html which I test and returns a 200 但我的没有 https://bookssorted.blob.core.windows.net/b2c/selfasserted.html

这个 article 谈论使用这个 PUT https://myaccount.blob.core.windows.net/?restype=service&comp=properties HTTP/1.1 但我如何 运行 这个?

编辑:我正在使用 Azure 存储资源管理器,我在 blob 上设置了这些规则,但它仍然没有从 test-cors.org 返回 http 200

EDIT2:这是 url 向身份验证策略发出请求,该策略加载请求加载 blob

的页面

https://login.microsoftonline.com/bookssorted.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_bookssortedAuthenticationPolicy&client_Id=35f308cd-8914-4035-9f62-cec7600c1727&nonce=defaultNonce&redirect_uri=https%3A%2F%2Flocalhost%2Fbookssorted%2Fsecure%2Fsuccess&scope=openid&response_type=id_token&prompt=login

EDIT3:headers 根据要求

为了使 cross-origin request 成功,请求必须匹配 CORS 配置。这包括 request originrequest headersexposed (response) headers。那里的任何不匹配都会导致请求失败。

如果来源已知,则必须在 CORS 规则中指定 URL(包括协议和端口号,如果适用)。如果来源未知,您可以指定 * 作为来源,所有 URL 都可以提出此类请求。

请求 headers 和公开 headers 也是如此。由于对 Azure 存储的不同请求使用不同的请求 headers 和 return 不同的响应 headers,因此建议在 CORS 规则中将这些值设置为 *。这将确保接受所有 request/response headers。