简体   繁体   English

Azure CDN CORS 设置

[英]Azure CDN CORS setup

New at this, so forgive me if the answer is obvious.对此很陌生,如果答案很明显,请原谅我。

I created a CDN for use with a standard javascript library (a commercial graphing library).我创建了一个 CDN 用于标准 javascript 库(一个商业图形库)。

The library has many files, and is present in 4 directories (modules, fonts, styles etc)该库有很多文件,存在于 4 个目录中(模块、fonts、styles 等)

I stored all the above in a storage account, and then created anf linked a CDN account to it.我将以上所有内容存储在一个存储帐户中,然后创建了一个将 CDN 帐户链接到它的 anf。 The access is anonymous, as it will be accessed by IOT devices that need the javascript libraries fr operation (and the devices have insufficient memory to serve the files themselves).访问是匿名的,因为需要 javascript 库 fr 操作的 IOT 设备将访问它(并且设备没有足够的 memory 来提供文件本身)。

All seemed to work, except I am getting CORS policy errors, when the library tries to access a font in the same CDN, but in a different directory.一切似乎都工作,除了我得到 CORS 策略错误,当库尝试访问同一个 CDN 中的字体,但在不同的目录中。

Here is the error in the web browser这是web浏览器中的错误

192.168.0.202/:1 
   Access to font at 'https://xxx.azureedge.net/htmlelements/styles/font/smart-icons.woff2' from origin 'http://192.168.0.202' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.enter code here

Is there a way to globally cross allow access of files in the same cdn, but in different directories?有没有办法全局交叉允许访问同一cdn中的文件,但在不同的目录中? (I looked at the online help, and got nowhere. (我查看了在线帮助,但一无所获。

Thanks谢谢

I added this line in my part of the html page我在 html 页面的部分中添加了这一行

<meta http-equiv="Access-Control-Allow-Origin" content="*"/>

I also added我还添加了

DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");

before my first server.on() routine in the asyncwebserver responses area on the server在服务器上的 asyncwebserver 响应区域中我的第一个 server.on() 例程之前

The errors seem to have gone away.错误似乎消失了。

Not sure if that is what is required, but willing to take suggestions if there is anything incomplete or wrong.不确定这是否是必需的,但如果有任何不完整或错误的地方,愿意接受建议。

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM