在 ember-cli 服务器上为静态文件设置 CORS [英] Setting CORS for static files on ember-cli server
本文介绍了在 ember-cli 服务器上为静态文件设置 CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在内置 ember-cli 服务器上对字体文件(或任何其他静态资源)的请求设置 CORS?
How do I set CORS on requests for fonts files (or any other static resource) on the built in ember-cli server?
这是错误信息,仅供参考:
This is the error message just for reference:
Font from origin 'http://some-domain:4200' 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:61277' is therefore not allowed access.
推荐答案
在 config/environment.js 的 ENV 中添加以下内容:
Add the following to ENV in config/environment.js:
module.exports = function(environment) {
contentSecurityPolicyHeader: 'Content-Security-Policy',
contentSecurityPolicy: {
// ... other stuff here
'font-src': "'self' http://some-domain:4200",
},
}
这篇关于在 ember-cli 服务器上为静态文件设置 CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文