我配置了我的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规则......
关于如何解决这个问题的任何想法?