虽然我在当地工作一切都很完美,现在我上传到托管,字体被我从未听说过的东西(CORS)阻止.字体(和css,js等)位于子域中,因为URL由索引解析(因此路径在域中不起作用).css/js工作正常.
这是Web控制台(firefox)中的输出:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /fonts/Oxygen-Regular.ttf. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
downloadable font: download failed (font-family: "Oxygen-Regular" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed source: /fonts/Oxygen-Regular.ttf styles.css:10:12
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /fonts/Montserrat-Regular.ttf. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
downloadable font: download failed (font-family: "Montserrat-Regular" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed source: /fonts/Montserrat-Regular.ttf styles.css:6:12
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /fonts/glyphicons-halflings-regular.woff2. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
downloadable font: download failed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed source: /fonts/glyphicons-halflings-regular.woff2 bootstrap.css:267:12
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /fonts/glyphicons-halflings-regular.woff. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
downloadable font: download failed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:2): bad URI or cross-site access not allowed source: /fonts/glyphicons-halflings-regular.woff bootstrap.css:267:12
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /fonts/glyphicons-halflings-regular.ttf. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
downloadable font: download failed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:3): bad URI or cross-site access not allowed source: /fonts/glyphicons-halflings-regular.ttf bootstrap.css:267:12
我搜索了这个问题,但我找不到字体和确切的错误消息的这个特定问题.
编辑:
修复方法是为服务文件的域/文件夹启用标头.配置可以位于虚拟主机块中,也可以位于.htaccess文件中(位于文件所在的文件夹中).我更喜欢在vhost块中设置它:
<IfModule mod_headers.c>
    SetEnvIf Origin "https://(www|sub1|sub2|sub3).domain.com)$" ACAO=$0
    Header set Access-Control-Allow-Origin "%{ACAO}e" env=ACAO
    Header set Access-Control-Allow-Methods "GET"
</IfModule>
在此示例中,Access-Control-Allow-Origin将仅发送列入白名单的域和子域的标头.我重定向domain.com到www.domain.com所以这个例子不接受没有域www.
Mar*_*ged 10
您的浏览器抱怨缺少标题:Access-Control-Allow-Origin
由于缺少此标头,因此您的浏览器不知道所需的访问权限是合法的.查看http://enable-cors.org并选择适合您服务器的配置.
您需要配置存储字体的服务器!
| 归档时间: | 
 | 
| 查看次数: | 25096 次 | 
| 最近记录: |