is there a guide on how to set up custom domains w...
# help
a
is there a guide on how to set up custom domains without using route53, or is this not supported?
t
custom domain on what construct?
a
Api and ReactStaticSite
t
here's an example: https://docs.serverless-stack.com/constructs/v1/Api#using-externally-hosted-domain The thing that's tricky is your ApiG needs to serve a valid certificate, you should just be able to do
new Certificate
and aws will email you to confirm ownership of the domain
that example imports an already existing cert (if you created it in the ui)
a
where do I do new Certificate?
t
Copy code
cdk: {
        certificate: new Certificate(props.stack, "cert", {
          domainName: dns.domain,
        }),
      },
something like that
a
and that doesn't always create a new certificate for each deployment?
ah, or, I guess it doesn't really matter if it's always a new cert, as long as it's valid?
t
it won't create a new cert every deployment, remember with the way cloudformation works it only makes changes if your stack definition changes in a meaningful way
just like doing
new StaticSite
won't create a new one every deployment
a
haha, right!
f
@Adrian Schweizer where is ur domain hosted? We will add an example for the domain registrar.
a
@Frank i have one on namecheap
@thdxr I tried it like this, but get the error message
A valid certificate is required when "isExternalDomain" is set to "true".
Copy code
customDomain:
            scope.stage === "prod" ? {
               isExternalDomain: true,
               domainName: "<http://api.mydomain.com|api.mydomain.com>",
               cdk: {
                  certificate: new Certificate(this, "apicert", {
                     domainName: "<http://api.mydomain.com|api.mydomain.com>",
                  }),
               },
            } : undefined,