hosting fonts on azure cdn - CORS support

2019-01-25 11:11发布

问题:

I cannot get azure blob storage hosted fonts exposed via azure cdn working in IE or Firefox.

I believe this is because of @font-face cross-domain issues (CORS) and the normal solution is to add an Access-Control-Allow-Origin header. I know that most CDNs now support this but am assuming that Azure still doesn't. Can anyone confirm this?

If this is the case, are there any workarounds?

回答1:

This is no longer true, azure supports CORS

http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx

and a little guide to adding fonts to your azure cdn:

http://www.devtrends.co.uk/blog/hosting-web-fonts-in-azure-blob-storage-using-the-new-cors-support



回答2:

The CDN doesn't modify the headers from the origin, so it responds with whatever headers blob storage emits. Blob storage does not support CORS headers.

I'm surprised to learn that @font-face has cross-domain restrictions, but it appears that you're right (for Firefox and IE).

If you have that option, you could put the fonts on a cloud service (rather than blob storage) behind the CDN and emit the right headers there.



回答3:

Your assessment is correct.

As a workaround, our company is utilizing Google storage (which supports CORS).

I would also suggest voting up this issue so the Azure team knows how many people are running into it.

http://www.mygreatwindowsazureidea.com/forums/34192-windows-azure-feature-voting/suggestions/2850796-support-cross-origin-resource-sharing-cors-via-a



回答4:

I can use fonts, without setting up the CORS option anyway. I'm linking my fonts directly to the blob storage, and not a CDN, since this one does not supports the CORS from the blob.