我将我的 blobstorage 配置为支持 CORS 请求。但是在我的博客上,它仍然给我从我的 CDN 检索到的字体错误。
Font from origin 'http://cdn.marcofranssen.nl' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://marcofranssen.nl' is therefore not allowed access.
我使用以下代码通过一个简单的控制台应用程序在我的 blob 存储上启用了 CORS。
class Program
{
static void Main(string[] args)
{
var creds = new StorageCredentials("myAccountName", "myKeyValue");
var csa = new CloudStorageAccount(creds, true);
ConfigureCors(csa);
}
private static void ConfigureCors(CloudStorageAccount storageAccount)
{
var blobClient = storageAccount.CreateCloudBlobClient();
var serviceProperties = blobClient.GetServiceProperties();
var cors = new CorsRule();
cors.AllowedHeaders.Add("*");
cors.ExposedHeaders.Add("*");
cors.AllowedOrigins.Add("*");
cors.AllowedMethods = CorsHttpMethods.Options | CorsHttpMethods.Get;
cors.MaxAgeInSeconds = 3600;
serviceProperties.Cors.CorsRules.Clear();
serviceProperties.Cors.CorsRules.Add(cors);
blobClient.SetServiceProperties(serviceProperties);
serviceProperties = blobClient.GetServiceProperties();
}
}
通过在最后一行进行调试,我看到属性/cors 已成功应用。我的属性中有一个 CORS 规则...
关于如何解决这个问题的任何想法?