Custom API Domains
Serve your project’s API on your own domain — api.yourproduct.com instead of api.foir.dev — so your frontend’s network traffic stays entirely on your brand.
How it works
A custom API domain is cosmetic routing. Requests through it behave exactly like requests to api.foir.dev:
- Authentication is unchanged. Every request still carries your project’s API key (and user token where applicable). The domain never grants access by itself — a request without a valid key fails identically on either hostname.
- The key still selects the project. Your key is bound to its project; the domain doesn’t change that. As a safety check, the platform rejects requests whose custom domain belongs to a different project than the key’s — you can’t accidentally (or deliberately) serve project A’s data dressed as project B’s API.
- Rate limits and errors are identical on both hostnames, and so is Foir’s own response cache.
- Foir’s edge cache is not. It serves
api.foir.devalone. Reads on your own domain are cached near your visitors only if your own CDN is set up to cache them: see On your own API domain, with the recipe for Cloudflare.
TLS is provisioned automatically: once your domain is verified, the first request triggers certificate issuance (Let’s Encrypt), and renewal is handled for you.
What’s served on a custom API domain
| Path | Purpose |
|---|---|
/graphql (and /graphql/ws) | The GraphQL API, including subscriptions |
/cdn/graphql | The shared endpoint: the reads that are the same for every visitor, which your own CDN may store |
/schema | Introspection for codegen |
/api/files/* | File upload endpoints |
/health/live | Answers 200 while the API is up, for an uptime check |
Any other path answers 404. An API domain serves the API and nothing else: it shows no login page and has no sign-in routes.
Everything else about your integration — headers, SDK configuration, tokens — works as documented for api.foir.dev; you only change the base URL.
Setup
Register the domain yourself in the console, under Settings > API domains. A config’s customDomains are login domains, so foir push registers no API domain. You need the domains:write permission, which the Project manager and Workspace manager roles both confer. See Team Members.
Registering prints two DNS records to add at your DNS provider:
-
CNAME — points your domain at Foir’s edge:
Type CNAME Name api.yourproduct.com Value api-edge.foir.dev -
TXT — proves you control the domain:
Type TXT Name _foir-challenge.api.yourproduct.com Value foir-verify=<token from registration>
After adding both records (allow a few minutes for DNS propagation), the domain is verified and goes live. It is not cached near your visitors until your own CDN is set up for it: On your own API domain has the recipe for each CDN. The first HTTPS request may take a moment while the certificate is issued; retry once and it’s warm from then on.
Who owns a hostname
Registering a hostname does not reserve it. Proving control does.
More than one project can hold a pending claim on the same hostname at once, and the first one to publish the matching _foir-challenge TXT record becomes its single verified owner. Everyone else’s claim stays pending and never issues a certificate. This means nobody can take a hostname off you by registering it first, and equally that registering early does not hold your place: add the DNS records to make the claim real.
Pending claims are cleared after seven days. If yours expires before the DNS records are in place, register it again — nothing else is lost.
Pointing your app at it
Change the base URL — nothing else:
const response = await fetch("https://api.yourproduct.com/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_FOIR_API_KEY,
},
body: JSON.stringify({ query, variables }),
});If you generate types from introspection, point codegen at https://api.yourproduct.com/schema with the same key you ship — the schema it sees is the schema that key sees (see scoped keys).
Troubleshooting
- TLS handshake fails on the very first request — certificate issuance happens on first contact with a newly verified domain. Retry after a few seconds.
403 This API domain is not bound to the key's project— the API key in the request belongs to a different project than the domain. Use the key of the project the domain was registered for.404 The API is not served on this domain— the request went to a domain you registered for something else, such as your login domain. Only an API domain serves the API. Send the request to your API domain, or toapi.foir.dev.404 page not found— the path is not one of those listed under What’s served on a custom API domain. An API domain answers nothing else. A login page lives on a login domain.- Certificate stops renewing — almost always a removed or changed CNAME. Confirm
api.yourproduct.comstill points atapi-edge.foir.dev. - Verification says the hostname is already verified elsewhere — another project published the challenge record for it first and now owns it. If that project is also yours, remove the domain there before claiming it here.
- The domain vanished before you finished — pending claims expire after seven days. Register it again, then add the DNS records.
- Custom login domains are separate. White-label hosted sign-in (
login.yourproduct.com) is configured per auth client viacustomDomains— see Config reference, and SPA (no backend) for what a verified login domain unlocks. A login domain does not serve the API. An API domain shows no login page and never carries login sessions or cookies; it is header-authenticated only.