Search code examples
amazon-web-servicesamazon-s3httpssingle-page-applicationamazon-cloudfront

SPA on AWS S3 bucket using CloudFront with non WWW


I’m deploying a SPA in a S3 bucket. I’m using cloudfront to work through https. I need to redirect or delete the www in my domain (example.com). I tried this process:

  • create a s3 bucket to the www domain (www.example.com) and redirect all requests to the default domain (example.com)
  • create a distribution for www domain (www.example.com)
  • create an A type record in Route53 that points to the www distribution

The result is that it’s not redirecting to the non-www bucket. What is happening is that its waiting to find index.html (configured in the default root object) of the www bucket and is thus not redirecting to the other bucket (the non www one)

This is my S3 configuration: enter image description here

enter image description here

enter image description here

enter image description here

And Cloudfront configuration: enter image description here

enter image description here enter image description here


Solution

  • Based on OP's feedback in the comment section, changing the CloudFront origin to use the website endpoint works.