Serverless-next.js: Use custom domain without subdomain

Created on 27 Sep 2019  路  9Comments  路  Source: serverless-nextjs/serverless-next.js

Hello,
Thanks for the NextJS 9 compatibility!
I was wondering if it was possible to use the custom domain functionality without the subdomain because when I set it as so:

inputs:
    domain: ["example.com"]

It throws Error: "domain" is a required input.

next component

Most helpful comment

I'm trying to do have a wild card instead of www
E.g.
domain: ["*", "example.com"]
However going to this https://example.com doesn't work anymore.
Any ideas on how to get the wild card to work?

All 9 comments

@ulysset try www for the subdomain. I think that works for the naked domain, i.e. http://example.com

Thanks, @danielcondemarin but it throws this error :
InvalidViewerCertificate: The certificate that is attached to your distribution doesn't cover the alternate domain name (CNAME) that you're trying to add. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

So I issued in the AWS Console Certificate Manage the www subdomain but still returned this same error.
For the moment I directly went into CloudFront and manually selected the SSL Certificate but it still doesn't work either hahaha, I'll wait a bit longer because it might need to propagate.

NB: the CloudFront URL (xxxxxx.cloudfront.net) works perfectly.

You need to issue a single certificate that covers both domains. Save yourself any hassles in the future and issue a certificate that covers both the wildcard subdomain *.domain and the naked domain.

Thanks @Gabrola and @danielcondemarin I managed to make it work with https://www.example.com and https://example.com doesn't work, so I'll try to find a solution to map it to the www subdomain so I guess it's not possible to use this plugin without a subdomain automagically?
Should we label this issue as "improvement"?

This is a bug in @serverless/domain. This should fix it serverless-components/domain#9. In the meantime, just add the naked domain as an alias manually to your cloudfront distribution through the AWS console.

@danielcondemarin hello, this PR merged yesterday. Can you update @serverless/domain versIon to 6.1.0?

The package has been updated and it works perfectly.
So I can use www.example.com and example.com!
My config:

nextApp:
  component: "serverless-next.js"
  inputs:
    domain: ["www", "example.com"]

I'm trying to do have a wild card instead of www
E.g.
domain: ["*", "example.com"]
However going to this https://example.com doesn't work anymore.
Any ideas on how to get the wild card to work?

Bump!

Was this page helpful?
0 / 5 - 0 ratings