Skip to content

www -> root domain redirect Cloudfront clash #82

Description

@vinnyt123

Following the tutorial for a www -> root domain redirect (e.g www.example.com -> example.com) https://serverless-stack.com/chapters/setup-www-domain-redirect.html, it directs you to set up a new cloudfront distribution for the www subdomain.

This means the www subdomain can no longer be an alternate domain name (CNAME) record for this cloudfront distribution or this error occurs on deploy:

Error: The domain "www.example.com" is already in use by another website or CloudFront Distribution.
    at updateCloudFrontDistribution (/var/task/utils.js:688:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

This is caused by

website/src/utils.js

Lines 103 to 104 in 6f87650

if (config.domain && config.domain === config.nakedDomain) {
config.domain = `www.${config.domain}`
automatically adding the www alternate domain name (CNAME) record when it is not wanted in this case.

I suggest an option should be added to not include this www alternate domain name (CNAME) for the cloudfront distribution as it makes this style of www redirect impossible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions