I work on a site builder project and put the generated sites as Single Page Application in a S3 bucket. This bucket is behind a CloudFront distribution. I’ve added a CNAME to my domain and a lambda function to route subdomains to single folders. For example:
my-site-alias.sitebuilder.xyz –> will internaly route to s3.website.url.amazon.com/my-site-alias
This works like i expected. But now i got struggeling. How can my clients put their custom domains before mine? I’ve tested with another domain like testdomain.com and added a CNAME to my custom domain. When i now visit the domain i get an 403 error.
The request could not be satisfied. Bad request. We can’t
connect to the server for this app or website at this time. There
might be too much traffic or a configuration error. Try again later,
or contact the app or website owner. If you provide content to
customers through CloudFront, you can find steps to troubleshoot and
help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
So how do i can add a custom domain before my custom domain with CloudFront and lambda@edge?