Currently, Sails serves the images hosted in assets/images folder, however, I need a different approach because the images will be hosted in a CDN system (AWS Cloudfront), so the images' URLs follow a structure like this:
https://hdfhhfh.cloudtfront.net/images/image.jpg
Therefore, How can I approach this?, How can I approach this in order to Sails automatically generate the URL for me?
For dev env, it's ok, for production env I need all the images in HTML/EJS to point to the CDN.
What you can do after uploading the images to S3 is:
In your Sails config (e.g. custom.js) add a global var like:
images_url: 'https://images.example.com/'
then return this URL concatenated with the images/image.jpg
e.g ${images_url}images/image.jpg
from your API to your frontend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With