Hi, I'm having a bit of an issue with using a cust...
# sst
p
Hi, I'm having a bit of an issue with using a custom domain with an SST ApolloAPI that I'm hoping someone can help with. I'm creating a custom domain object (with domainName, hostedZone, path and certificate) in the same way I've done for SST Apis but when I try to access it after deploying I just get back a "not found" error. If I use the default AWS endpoint it works fine, it's just the custom domain version. I'm pretty new to AWS and SST so maybe I've missed something daft, but given it works for standard Apis and I'm using the same function to create the domain object, I don't think it's me...
I can see any entry listed for the custom domain in Route 53 so it made it that far.
Here's where I create the Apollo API (domain URL doesn't work):
Copy code
// Create a Apollo API
    const api = new ApolloApi(this, "Api", {
      cors : true,
      customDomain : customDomain,
      defaultFunctionProps : defaultFunctionProps,
      server : "graph-server.handler",
    });
Here's where I create a standard API (domain URL works):
Copy code
const api = new sst.Api(this, "Api", {
      defaultFunctionProps,
      customDomain,
      cors: true,
      routes: {
        "GET /sites/{site_id}/google/request-auth": {
          handler: "google/request-oauth.handler",
        },
        "GET /google/oauth-callback": {
          handler: "google/oauth-callback.handler",
          permissions: [ auroraClusterPolicy, auroraSecretPolicy ],
        },
      },
    });
f
Hey @Phil Astle, that looks right to me. It might take a bit for the custom domain to be up. Is it working now by any chance?
A quick check is to do a dns look up and see if the nameservers matches what you have in Route53 - https://mxtoolbox.com/DNSLookup.aspx
p
Thanks for the reply @Frank. I've been running in debug so it only stays up for maybe an hour or two at most. The rest work straight away though, when I run like that. I'll try a full deploy and see if that makes a difference.
Looked up the entries in Route53 for the custom domain. It goes to a an intermediate execute-api domain but they both resolve to the same IP address. If my custom domain and path (the path is just api) are https://mydomain.com/api do I need to put anything on the end because it's a graphql service? I don't when I run it using the non-custom domain URL but I haven't specified a path for that.
f
You shouldn’t need anything after the custom domain path. Is it possible to DM me a couple of things: • the custom domain URL; • the non-custom domain URL; and • a screenshot of this custom domain in the API Gateway console (Configurations tab and the API mappings tab)
j
p
I don't know. The domain name, path and ARN region match the rules above though
f
@Phil Astle Got ur DM. Can you try adding an ending slash to the custom domain url?
See if that works.
p
That did it... Schoolboy error?
f
lol I actually just noticed it too after spinning up a new api with path mapping
if a basepath is not set, with or without trailing
/
both works.
p
So I'm not completely daft then - that's good to know 🙂
f
but if set, u need a trailing
/
it seems
p
For all the other standard APIs I didn't have any root route set, I always had paths you need to navigate along - that'll be why I didn't notice it before.
f
Yeah same here.
p
Thanks for that - I'd been banging my head against the wall for a while with that one! I tried lots of other combinations of URL but never thought to just try adding a forward slash to the end.
f
Btw, did u add the custom domain url as an output, and then copied and pasted it from the stack output?
p
We build up a string to write to the console of what the domain url should be, if that's what you mean?
f
I’m asking b/c
api.customDomainUrl
doesn’t has the trailing slack, and I wonder if that got u confused.
p
Ah I see. No, we're doing this currently:
Copy code
this.addOutputs({
      ApiId: api.httpApi.apiId,
      PrivateApiEndpoint: api.httpApi.apiEndpoint,
      PublicApiEnpoint: `https://${customDomain.domainName}/${customDomain.path}`,
    });
Though getting it off the api object seems better so I'll change it to grab it from there instead and manually add the trailing slash
f
Yeah.. I will push a fix later today to add a trailing slash to
api.customDomainUrl
.
p
Great! I'll put in a temporary workaround for the missing slash for now then! Thanks for all the help 🙂
f
Hey @Phil Astle, added the change in v0.36.0.
api.customDomainUrl
will return with trailing slash if custom domain
path
is configured.
p
I just noticed and upgraded - trying it out now!
Looks good to me 🙂