![]() Origin protocol policy: Switch to “HTTPS Only”. ![]() Origin Domain Name: your heroku app host like.The only one that absolutely necessary - if you want CORS to work - seemed to be changing Allowed HTTP Methods to include OPTIONS.Ĭlick on “Create Distribution”. # hostname, will look like ``Ĭonfig.asset_host = ENV # set heroku config var RAILS_ASSET_HOST to your cloudfront Btw, you might not need to care about CORS here, but one reason you might is if you are serving any fonts ( including font-awesome or other icon fonts!) from Rails static assets. So while I’m not an expert on this stuff, i’m going to tell you what I was able to discover, and what I did to set up Cloudfront as a CDN in front of Rails static assets running on heroku - although there’s really nothing at all specific to heroku here, if you have any other context where Rails is directly serving assets in production.įirst how I set up Rails, then Cloudfront, then some notes and concerns. And while there are lots of blog posts you can find on this topic, I found many of them outdated (Rails has introduced new API Cloudfront has also changed it’s configuration options!), or otherwise spotty/thin. While heroku has an article on using Cloudfront, which even covers Rails specifically, and even CORS issues specifically, I found it a bit too vague to get me all the way there. Heroku really recommends using a CDN in front of your Rails app static assets - which, unlike in non-heroku circumstances where a web server like nginx might be taking care of it, otherwise on heroku static assets will be served directly by your Rails app, consuming limited/expensive dyno resources.Īfter evaluating a variety of options (including some heroku add-ons), I decided AWS Cloudfront made the most sense for us - simple enough, cheap, and we are already using other direct AWS services (including S3 and SES).
0 Comments
Leave a Reply. |