How to setup a custom assets domain

If you want to use your own domain for assets instead of the default domain a.storyblok.com you can use a Cloudfront distribution to forward requests to Storyblok’s origin servers.

The following tutorial shows the how you can setup your own domain for Storyblok’s assets using Amazon AWS. If you don’t have a Amazon AWS account yet signup here.

1. Create a SSL certificate

Create a SSL certificate for your domain using AWS Certificate Manager in the region us-east-1 (N. Virginia). It’s important that you create the certificate in us-east-1 because CloudFront only accepts certificates from this region.

2. Create a CloudFront distribution

Create a CloudFront distribution and defining following settings:

  • Origin Domain Name: a.storyblok.com.s3.amazonaws.com
  • Compress Objects Automatically: Yes
  • Alternate Domain Names (CNAMEs): assets.yourdomain.com
  • SSL Certificate: Custom SSL Certificate (Choose your certificate)

Leave the default value for the rest of the settings.

3. Point your domain to CF

After the CloudFront distribution has been created and has the status active change your DNS settings of your domain to point to YOURID.cloudfront.com.

4. Replace the domain in your app

Create a helper that replaces the default domain of a image field url with your new custom domain.

Example in Javascript:

function img(src) {
  return (src || '').replace('//a.storyblok.com', '//assets.yourdomain.com')
}

Documentation