serverless-nextjs / serverless-next.js

⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
MIT License
4.44k stars 451 forks source link

CNAMEs & redirect #254

Closed romainquellec closed 3 years ago

romainquellec commented 4 years ago

Currently, I handle one domain, and one redirect.

My main domain is www.website.com : cloudfront, lambda, ect, handle by this plugin. My sec record is website.com and is related to a cloudfront and a S3 bucket to redirect everything to the first one.

Currently, I think I can't just handle www.website.com with cloudfront, because it always ask for the root domain.

CNAMEAlreadyExists.. blablabla

Am I right or did I miss something ?

romainquellec commented 4 years ago

I will ask differently: Is it possible to handle only "www.website.com", and not care about website.com ?

OisinOKeeffe commented 4 years ago

HI, I am using this plugin for various www domains. If the subdomain is configured as "www" it handles the non "www" route as an alias on the cloudfront and creates the corresponding route53 entries. i.e. subdomain = "www" domain = "example.com" both www.example.com and example.com requests are handled correctly

romainquellec commented 4 years ago

Exacly, but not option to handle one or another.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Arditc commented 4 years ago

Hi, Is there any updates on this? Because I'm facing the issue where I'm using domain.com in cloudfront to s3 bucket (to redirect to www) and www.domain.com to go to the serverless nexjs application.

So I only want to effect www.domain.com cname and not domain.com

dphang commented 3 years ago

I think the domain inputs have been updated with domain + domainType (apex or www or both). There is also domainRedirects to handle www to non-www (or vice-versa) redirects, and you can also use aliases and certificateArn if you do want to manage the ACM cert and domains outside of the component.

So I think this should give more flexibility and solve the issue. Please check the readme for guidance on these inputs.

Hopefully this solves the issue - closing it now. Please create a new issue if you have trouble with these inputs.