我在我的Azure帐户上设置了一个新的Blob存储帐户,并将其配置为允许使用以下配置的CORS:
serviceProperties.Cors = new CorsProperties();
serviceProperties.Cors.CorsRules.Add(new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post | CorsHttpMethods.Delete,
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 1800 // 30 minutes
});
但是我仍然从我的js代码中收到以下错误:
Origin <MY-SITE-URL> not found in Access-Control-Allow-Origin header
查看图像的响应标头,我看到:
Access-Control-Allow-Origin: *
那为什么不起作用呢?
最佳答案
您是否将xmlhttprequest的withCredentials属性设置为true?如果是,浏览器将拒绝通配符Access-Control-Allow-Origin。
查看以下链接以获取更多有用的信息:
Azure storage CORS returns origin wildcard and fails in browser
https://msdn.microsoft.com/en-us/library/azure/dn535601.aspx
关于javascript - 浏览器忽略的Azure Blob CORS访问控制允许来源,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27896791/