gpt4 book ai didi

google-chrome - Chrome中CDN背后的woff2字体出现CORS问题

转载 作者:行者123 更新时间:2023-12-03 13:44:34 27 4
gpt4 key购买 nike

我有一个带有Cloudfront CDN的S3存储桶。在该存储桶中,我有一些woff2字体,这些字体自动用内容类型octet-stream标记。尝试从实时生产网站上的CSS文件加载该字体时,出现以下错误:

Access to Font at 'https://cdn.example.com/fonts/my-font.woff2' from origin 
'https://www.live-website.com' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://www.live-website.com' is therefore not allowed access.

事实是, curl 表明存在 Access-Control-Allow-Origin:
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 98488
Connection: keep-alive
Date: Wed, 08 Aug 2018 19:43:01 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Max-Age: 3000
Last-Modified: Mon, 14 Aug 2017 14:57:06 GMT
ETag: "<redacted>"
Accept-Ranges: bytes
Server: AmazonS3
Age: 84847
X-Cache: Hit from cloudfront
Via: 1.1 <redacted>
X-Amz-Cf-Id: <redacted>

在Firefox中一切正常,因此我认为Chrome浏览器正在进行额外的验证,该验证会阻止我的字体。

最佳答案

原来,问题实际上出在Content-Type上。一旦将内容类型更改为application/font-woff2并使这些woff2文件的缓存无效,一切就顺利进行了。

关于google-chrome - Chrome中CDN背后的woff2字体出现CORS问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52893199/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com