Have set up Heroku deploy - struggling with S3 + CDN for assets.
config.yml
:
s3_upload_bucket_name: "bucket_name_uploads"
s3_bucket_name: "bucket_name"
aws_access_key_id: "MY_KEY"
aws_secret_access_key: "MY_SECRET"
asset_host: 'my-cloudfront-cdn-1.cloudfront.net'
user_asset_host: 'my-cloudfront-cdn-2.cloudfront.net'
Without CDN, I was able to upload and get assets from my s3 buckets
With CDN, I’m getting console errors for assets such as:
GET https://images/listing_images/images/2/small_3x2/red-dress.jpg?1476304034 net::ERR_NAME_NOT_RESOLVED
So my CDN isn’t be prepended to the GET request.
I’m also getting error:
(index):1 Font from origin 'https://my-cloudfront-cdn-1.cloudfront.net' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://my-app.herokuapp.com' is therefore not allowed access.
So I think I’m setting up my Cloudfront distributions wrong. Can anyone assist in setting these up properly?
Cloudfront for ASSET_HOST
:
Cloudfront for USER_ASSET_HOST
:
I understand the headers I’ve put in are very open, just to try to get it to work based on this answer.
But are my origins wrong? Does one CDN need to point to a bucket and one to the site? Do they both need to point to buckets? Do they need to point to different buckets? Perhaps I am confused as to the asset process…
- Assets upload direct to s3 buckets.
- Assets are delivered via CDN to the browser, from the buckets. So does my CDN need to point to a bucket then?
Thanks for any help!