Can't seem to solve this, im pusing a custom bootstrap css&fonts into my azure cdn but in chrome I keep getting "Font from origin 'http://azxxxxxx.vo.msecnd.net' 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://localhost.domain:16300' is therefore not allowed access.
I modified my bootstrap css
font-face {
font-family: 'Glyphicons Halflings';
src: url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.eot');
src: url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.woff') format('woff'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
I've read a few stackoverflow posts, added the following to my webconfig
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/octet-stream" />
</staticContent>
Still have the same issue, any ideas?
Assuming you've uploaded fonts/CSS to Azure Storage fronted with Azure CDN.
You need to enable CORS on the storage to allow your site to access fonts cross-domain.
The complete steps are covered in Windows Azure Storage: Introducing CORS
Partial sample from the article (you'll need to get NuGet for recent Azure client libraries to build it):
private static void InitializeCors()
{
// CORS should be enabled once at service startup
// Given a BlobClient, download the current Service Properties
ServiceProperties blobServiceProperties = BlobClient.GetServiceProperties();
ConfigureCors(blobServiceProperties);
BlobClient.SetServiceProperties(blobServiceProperties);
}
private static void ConfigureCors(ServiceProperties serviceProperties)
{
serviceProperties.Cors = new CorsProperties();
serviceProperties.Cors.CorsRules.Add(new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Head,
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 1800 // 30 minutes
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With