Azure 存储。收到 403 [url](未启用 CORS 或未找到此请求的匹配规则。)

标签 azure web cors azure-blob-storage preflight

我正在开发一些网页,允许将文件从客户端直接上传到我的 azure 存储。 我的文件存储在门户中的 Azure BLOB 存储中。 为此,我使用 npm 中的“azure-storage”v2.8.1 包。

当我尝试创建容器时:

    const blobService = AzureStorage.createBlobServiceWithSas(storageUri, sasToken)
    blobService.createContainerIfNotExists(containerName, { publicAccessLevel: 'blob' }, (error, result, response) => {.....})

我遇到错误:

  1. OPTIONS [我的存储的 URL] 403(未启用 CORS 或未找到此请求的匹配规则。)

  2. 无法加载 [url 到我的存储]:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin” header 。

我确信 blob 连接字符串是正确的 - 我检查了它。 此外,我知道我可以在 azure.portal 上编辑我的存储的 CORS。 目前它是空的。

我是否需要添加/编辑一些 CORS? 有人知道解决方案吗?

最佳答案

Should I need to add/edit there some CORS? Do someone know solution?

是的,您需要为存储 Blob 服务添加 CORS 设置。默认情况下,每个服务都禁用 CORS。我们可以从这个article获得更多关于CORS的信息.

Note: CORS is not supported for Premium Storage accounts.

我们还可以从 Azure 门户进行设置。更多详情请引用截图。

enter image description here

关于Azure 存储。收到 403 [url](未启用 CORS 或未找到此请求的匹配规则。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50785255/

相关文章:

azure - 如何为 Azure VM 拥有域

javascript - 登录后从网站获取数据,客户端

angularjs - 使用Nginx作为代理以避免CORS

linux - 从 Windows Web 服务获取 Linux 服务器硬件信息

java - RESTful Web 服务在本地主机服务器中运行,但不在生产服务器中运行

ruby-on-rails - Rails 5.1 CORS - 如何为不同环境设置不同来源

node.js - Azure Function Node.js 无法为运行时启动新的语言工作线程 : node

azure - 调用 TelemetryClient.TrackEvent() 后是否能保证 Azure Application Insights 自定义事件的传递?

azure - 对于Azure DocumentDB输入绑定(bind),有没有办法从标题中获取文档ID?

javascript - 为什么在使用 "Grid"的 'semantic-ui-react' 组件时得到不正确的布局?