AnthonyGalli.com AnthonyGalli.com - 2 months ago 15
Ruby Question

Why is rails app rendering without CSS after creating Cloudfront distribution?

My rails app isn't loading the css or js files now upon trying to implement page cache via cloudfront.

I'm using heroku and I setup cloudfront based on these instructions:

https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn

Done: "To create a CloudFront distribution you will need an Amazon AWS account. Once logged in you can go to the CloudFront control panel and select ‘Create distribution’. When prompted for the delivery method, select 'Web’."

I then added to rails production.rb:

config.action_controller.asset_host = "d373p52igaakhgm9.cloudfront.net"


What could have gone wrong with www.anthonygalli.com? I think I followed all the steps.

Answer

If you inspect the network traffic on your site (e.g. using Developer Console in Chrome), you will notice there is a 403 Forbidden response to your cloudfront assets. It seems that your Cloudfront configuration is not quite correct. Check out http://stackoverflow.com/a/34898823/2611078 for some ideas.

Comments