:wave: can I have my api `customDomain` something ...
# help
k
👋 can I have my api
customDomain
something like api-hello.great.world.com ? let's say I own world.com domain from aws. I try something similar but when it's deployed the customDomain is still not what I named it
a
i faintly remember someone who had a similar problem
could it be that the construct just treats everything after the first dot as the domain
maybe show your setup and what it makes of it
i think this was the thread i remembered, its probably not exactly like your issue https://serverless-stack.slack.com/archives/C01JG3B20RY/p1650744821876789
f
Thanks @Adrian Schweizer!
Yeah this should work
Copy code
customDomain: {
  domainName: "<http://api-hello.great.world.com|api-hello.great.world.com>",
  hostedZone: "<http://world.com|world.com>",
}
k
Hmm, weird in my api stack I have :
Copy code
customDomain: getCustomDomain(app.stage as "prod" | "dev"),
where `getCustomDomain`: (it's an example)
Copy code
const getCustomDomain = (stage: "prod" | "dev") => {
  return {
    domainName: `${stage}-<http://api.great.world.com|api.great.world.com>`,
    hostedZone: "<http://world.com|world.com>",
  };
};
in seed I have
dev
environment where my backend and frontend is deployed but my frontend still calls random generated api domain ;/
I think I figured that out i should pass
_getCustomDomain_(_stack.stage as_ "prod"
|
"dev")
instead of app.stage. @Frank what's the difference with
stack.stage
and
app.stage
?
a
Do you deploy single stacks?
I think if you start or deploy with --stage dev, app.stage should be set correctly
Copy code
npx sst start --stage dev
if you use the functional construct, you'll probably have to add app to the parameter destructuring, or it will be null, but since you're using Typescript, it should warn you about that
k
@Frank just FYI this does not work
Copy code
customDomain: {
  domainName: "<http://api-hello.great.world.com|api-hello.great.world.com>",
  hostedZone: "<http://world.com|world.com>",
}
it does not pass the regex validation. That's what the error says
Copy code
Status: failed
  Error: 1 validation error detected: Value '<https://hello-api.world.hello.com>' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^(\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])$ (Service: AWSCertificateManager; Status Code: 400; Error Code: ValidationException; Request ID: e8516c2a-fade-494c-b163-6af0ed29bb92; Proxy: null)
Copy code
'<https://hello-api.world.hello.com>' is just an example but my domain naming is very similar
a
Are you sure you are defining it without the https:// ? Because according to regex101.com, it does match without it
k
@Adrian Schweizer wow you actually right. I had https:// in the front.
a
yeah, i had that problem too, previously
maybe the regex should be set up so that it allows an optional http(s):// prefix
it does say domainName, though, and not URL, so I guess it's correct currently