相关疑难解决方法(0)

Cloudfront CORS问题在Rails应用程序上提供字体

访问我的网站时,我一直收到来自控制台的错误消息:

font from origin 'https://xxx.cloudfront.net' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.example.com' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)

我尝试了一切:

但没有,零,虚无...

我在Heroku上使用Rails 4.1.

fonts ruby-on-rails heroku cors amazon-cloudfront

23
推荐指数
4
解决办法
6521
查看次数

Rails Passenger Glyphicon CORS Cloudfront NGINX问题

所以我知道stackoverflow是关于CORS Nginx,Cloudfront和Heroku的这些问题,但由于某些原因我不能让它工作.我一直在关注这个问题的答案:

如何使用rails,nginx和passenger配置`Access-Control-Allow-Origin`?

但是,我似乎无法弄清楚自定义代码块的放置位置:

config/nginx.conf.erb
Run Code Online (Sandbox Code Playgroud)

接下来,通过查找如下所示的块来编辑配置文件config/nginx.conf.erb:

location @static_asset {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    add_header ETag "";
} ...and add the two Access-Control lines:
Run Code Online (Sandbox Code Playgroud)

>     location @static_asset {
>         gzip_static on;
>         expires max;
>         add_header Cache-Control public;
>         add_header ETag "";
>         add_header Access-Control-Allow-Origin *;
>         add_header Access-Control-Request-Method *;
>     } That's it. This will work in production, but not in development, due to config.assets differences between the two.
Run Code Online (Sandbox Code Playgroud)

在我的Nginx配置中.我正在使用Phusion Passenger 5.0.23.Nginx配置在我从乘客那里取出的那个中没有位置@static_asset块.它确实有一个自定义配置部分,但这对我没用.我的glyphicons继续显示为盒子我如何让它工作?我也试过这个 Phusion Passenger + Heroku …

ruby-on-rails passenger heroku cors amazon-cloudfront

6
推荐指数
1
解决办法
377
查看次数