- 1 year ago 60
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:

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 = ""

What could have gone wrong with I think I followed all the steps.

Answer Source

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 for some ideas.