The site created in Rails 6 is displayed using Heroku.
I am using Amazon S3 for the image.
The image url on the site is as follows.
https://www.example.com/rails/active_storage/.../curry.jpeg
If you access the image url, it will be transferred to the following Amazon S3 url.
https://example.s3.ap-northeast-1.amazonaws.com/variants/...
Is it possible to change the address of Amazon S3 to url starting with https://www.example.com/
For static sites, it seems that you can change it using CloudFront and Route 53.
Is there any way to change it on a dynamic site using Heroku?
Or do I have to use another storage service instead of Amazon S3 to change url?
Is it possible to change the address of Amazon S3 to url starting with https://www.example.com/
S3 alone is not enough.You can customize the URL of the endpoint by placing other services in the first step.CloudFront is often used.(described later)
On static sites, it seems that it can be changed using CloudFront and Route 53.
Is there a way to change it on a dynamic site using Heroku?
I have no knowledge of Heroku, so I will answer from a general perspective.
When hosting web apps in the cloud, it is common to separate configurations between static and dynamic content.The following configurations may be considered for this time:
In particular, you may want to add an alternate domain name www.example.com
to CloudFront and refer to https://www.example.com/...
from the Rails app hosted by Heroku.
Using Various Origins in CloudFront Distributions - Amazon CloudFront
Using Custom URLs by Adding Alternate Domain Names (CNAME)—Amazon CloudFront
There was a document that might be relevant in Heroku (Heroku seems to refer to static content as "static assets").
Using Amazon CloudFront CDN|Heroku Dev Center
© 2024 OneMinuteCode. All rights reserved.