[Rails] Settings for loading web fonts in CloudFront on Heroku

Introduction

You can create a Rails app and place static files on the cloud front to speed it up. However, due to CORS (Cross-Origin Resource Sharing) issues, web font files cannot be read unless they are set properly. config.action_controller.asset_host = 'https://d1adsfkajflajflj.cloudfront.net'

Looking at past articles, it was hard to find because it was hidden in the Edit screen of CloudFront, so I will keep a record.

AWS Console In conclusion, as you can see in the official docs and in the web article, I was able to set the Whitelist Headers by washing the ʻUse Leagacy cache settings item. Add ʻAllowed Origin in the Whitelist Headers section and save. https://aws.amazon.com/jp/premiumsupport/knowledge-center/no-access-control-allow-origin-error/ スクリーンショット 2020-10-30 14.06.07.png

Reference article

Set Access-Control-Allow-Origin for Cloudfront Cached object http://www.366service.com/jp/qa/e9d300384bb16161a2f010337ac5128f

Using web fonts with S3 + CloudFront (FireFox compatible) --Qiita https://qiita.com/Oakbow/items/dae3d383d87d7d0c6344

Resolve the CloudFront "No'Access-Control-Allow-Origin' header is present" error https://aws.amazon.com/jp/premiumsupport/knowledge-center/no-access-control-allow-origin-error/

Recommended Posts

[Rails] Settings for loading web fonts in CloudFront on Heroku
Validation settings for Ruby on Rails login function
[Ruby On Rails] How to reset DB in Heroku
Challenge the settings for developing with vue.js on Rails 6
Definitely useful! Debug code for development in Ruby on Rails
Ruby on Rails Japanese-English support i18n
Deploy Rails on Docker to heroku
Settings for SSL debugging in Java
Deploy your Rails app on Heroku
Use Timecop in Rails web app to travel time on your browser
Note: nginx.conf settings for CORS in Exment on Lightsail + Docker (nginx) environment
Cloud IDE: Heroku couldn't be installed in the Ruby on Rails tutorial
[Ruby on Rails] About bundler (for beginners)
Ruby on Rails in Visual Studio Codespaces
Deploy to Heroku [Ruby on Rails] Beginner
Deploy a Java web app on Heroku
Explanation of Ruby on rails for beginners ①
Beginners create portfolio in Ruby on Rails
Create a Docker container for your development web server in Ansible on MacOS