1

I'm using cloudfront to serve assets for my rails app on heroku. Over http this works fine. But when I access my website via https, assets don't load, and I get this error:

Mixed Content: The page was loaded over HTTPS, but requested an insecure stylesheet. This request has been blocked; the content must be served over HTTPS 

Things I tried:

  • Adding https:// to the front of the URL in rails config.
  • Setting origin protocol policy to https only on cloudfront.
  • Installing Rack Cors.

1 Answer 1

1

Try setting this option

app/config/environments/production.rb

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true config.action_controller.asset_host = "<YOUR DISTRIBUTION SUBDOMAIN>.cloudfront.net" 

Documentation at https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn#testing comments a warning about this:

If you are wanting to serve Cloudfront assets using SSL you can simply use HTTPS on the distribution domain given to you by Amazon. Note, whilst you can create CNAME’s for this purpose, serving Cloudfront assets over your CNAME and SSL has an attached cost.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.