---
title: Custom domains
slug: custom-domains
summary: Serve a published App, or a Function's HTTP routes, on a LimiLake subdomain or on a hostname you own.
---

# Custom domains

A custom domain is another address for one published App, or for the HTTP
routes of one Function, in your Workspace. You can use a LimiLake subdomain
such as `reports.apps.limilake.app`, which works at once, or a hostname you
own, such as `reports.example.com`, which needs two DNS records.

The examples use a Workspace named `finance` and an App named `reports`.

## Before you start

- You need `owner` access to the Workspace. A member with `viewer` or
  `editor` access gets exit code 5 from these commands, and someone who is
  not a member gets exit code 4.
- The App must be published: push it to `main` first. A Function must
  declare at least one HTTP route.
- For your own hostname, you need to be able to add records in its DNS zone.

You run every step with `limilake workspace domain`. Owners also see a
**Custom domains** card on the Workspace's settings page in LimiLake.

## Use a LimiLake subdomain

Add a name under `apps.limilake.app`. It is active at once and needs no DNS:

```bash
limilake workspace domain add reports.apps.limilake.app --app reports --workspace finance
```

The name is one label of 3 to 40 characters: lowercase letters, digits and
inner hyphens. A few platform names, such as `www`, `api` and `admin`, are
reserved. To serve a Function instead, pass `--function` with its name as
`limilake function list` shows it:

```bash
limilake workspace domain add share.apps.limilake.app --function candidate-share --workspace finance
```

## Use your own hostname

1. Add the hostname:

   ```bash
   limilake workspace domain add reports.example.com --app reports --workspace finance
   ```

   The command prints the two DNS records to create. The domain starts in
   `pending_dns`.

2. Create both records in your DNS zone, exactly as `add` printed them:

   | Name | Type | Value |
   | --- | --- | --- |
   | `reports.example.com` | `CNAME` | `domains.limilake.app` |
   | `_acme-challenge.reports.example.com` | `CNAME` | `<token>.dcv.limilake.app` |

   The token in the second record is new for every domain you add, so copy
   it from the output. To read the records again, run
   `limilake workspace domain show reports.example.com --workspace finance`.

   For an apex domain such as `example.com`, which cannot have a `CNAME`, the
   first record is an `A` record instead:

   | Name | Type | Value |
   | --- | --- | --- |
   | `example.com` | `A` | the IPv4 address that `add` prints |
   | `_acme-challenge.example.com` | `CNAME` | `<token>.dcv.limilake.app` |

   Custom domains are served over IPv4 only. Remove any `AAAA` record on an
   apex hostname, or the check fails.

3. Check the records and wait until the domain is active:

   ```bash
   limilake workspace domain verify reports.example.com --wait=20m --workspace finance
   ```

   LimiLake also checks on its own, so you can close the terminal and come
   back. `--wait` checks every 15 seconds and prints each status it passes
   through. Without a duration it waits 10 minutes. It exits 1 if the domain
   stops in `error`, and 6 if it is not active in time.

4. Open `https://reports.example.com`.

If you do not publish the records within 72 hours of `add`, the claim expires,
the domain is removed and the hostname is free again.

> **Warning:** Keep the `_acme-challenge` record for as long as you use the
> domain. LimiLake checks it again regularly and needs it to renew the
> certificate. If it is gone for 72 hours, the domain stops serving and goes
> to `error`. If it stays gone for another 72 hours, LimiLake removes the
> domain and frees the hostname.

### Publish the records through Cloudflare

If the zone is on Cloudflare, LimiLake can create both records for you with
a Cloudflare API token that has Zone Read and DNS Edit on that zone. Keep the
token in a file and pass the file:

```bash
limilake workspace domain connect reports.example.com \
  --cloudflare-token-file ./cloudflare-token.txt --workspace finance
```

LimiLake uses the token for this one request and never stores it. The
command lists each record as `created`, `updated` or `unchanged`, then checks
the records at once. If other records are in the way at the same names, it
refuses with `record_conflict` and lists them. Add `--replace` to replace
them. At the hostname itself it replaces only `A`, `AAAA` and `CNAME` records,
never `MX` or `TXT`. At `_acme-challenge.<host>` it also replaces a `TXT`
record, such as one another certificate tool left there. Passing the token
itself as a flag value is refused.

## Statuses

`limilake workspace domain list --workspace finance` shows every domain of the
Workspace with its status. `show` adds the last thing the DNS check saw.

| Status | What it means for you |
| --- | --- |
| `pending_dns` | LimiLake has not seen both records yet, or one of them points somewhere else. Create or fix the records. |
| `verifying` | Both records were seen once. LimiLake needs to see them on two checks in a row, from every public resolver it asks. |
| `issuing_cert` | Ownership is proven and LimiLake is getting a certificate. If this takes more than 30 minutes, the domain goes to `error`. |
| `active` | The domain serves the App or Function over HTTPS. |
| `error` | The domain stopped. The output explains why in plain words. See [Troubleshooting](#troubleshooting). |
| `removing` | You removed the domain and LimiLake is cleaning up. It no longer serves. |

A LimiLake subdomain goes straight to `active`.

## What visitors see

The domain serves the same App with the same access:

- A members App still asks visitors to sign in with LimiLake.
- A [public App](./apps.md#public-apps) opens for anyone, with no sign-in.
- A Function domain passes each request path to the Function's routes, so
  `https://share.example.com/candidate` reaches a route declared as
  `@fn.post("/candidate")`. Paths under `/__limilake/` are not passed on.
  Cookies are not forwarded to the Function.

An App on your own hostname shares that domain with your other sites: cookies
you set for the parent domain also reach the App. Do not keep secrets in an
App's browser storage. A later owner of the same address could read what
visitors' browsers kept.

## Put Cloudflare's proxy in front

By default (`--edge direct`), your DNS points straight at LimiLake. This is
the recommended setup. If you want Cloudflare to proxy the hostname, switch
the domain to Cloudflare edge mode:

```bash
limilake workspace domain edge reports.example.com cloudflare --workspace finance
```

You can also pass `--edge cloudflare` to `add`. In this mode:

1. The command prints an edge secret once. No later command shows it again.
2. In Cloudflare, create a request header Transform Rule that sets the
   `X-Limilake-Edge-Secret` header to that secret on requests to the
   hostname. With it, `limilake.client_address()` in a Function returns the
   visitor's address instead of Cloudflare's.
3. The hostname record may be proxied. The `_acme-challenge` record must stay
   DNS only, so that it answers with its `CNAME`.

To get a new secret, run the same `edge ... cloudflare` command again and
update the Transform Rule. To go back, run `edge reports.example.com direct`.
Edge mode is only for your own hostnames, not for LimiLake subdomains.

## Limits

| Limit | Value |
| --- | --- |
| Your own hostnames per Tenant | 5 |
| LimiLake subdomains per Tenant, counting those removed in the last 30 days | 10 |
| Time to publish the DNS records after `add` | 72 hours |
| Time a removed LimiLake subdomain stays reserved for its Workspace | 30 days |
| Targets per domain | One App or one Function |

A hostname can belong to only one domain on LimiLake. If any Tenant already
uses it, `add` refuses it with `hostname_unavailable`.

## Remove a domain

```bash
limilake workspace domain remove reports.example.com --workspace finance
```

The domain stops serving at once. The command asks for confirmation; add
`--yes` to skip it. Then delete the two DNS records.

A removed LimiLake subdomain stays reserved for its Workspace for 30 days:
only that Workspace can add it again, and it still counts toward the
subdomain limit until then.

## Troubleshooting

Run `limilake workspace domain show <hostname>` first: it shows the status,
the error reason and what the last DNS check saw.

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| Stays in `pending_dns` | A record is missing, has a typo, or has not reached the public resolvers yet. | Compare your records with `show`, wait for your DNS provider, then run `verify`. |
| Stays in `pending_dns` | The hostname is a `CNAME` to another target, or an apex hostname has other `A` or any `AAAA` records. | Point the hostname only at the value `show` lists. |
| Stays in `pending_dns` | `_acme-challenge` is a `TXT` record or a `CNAME` with an old token. | Replace it with the `CNAME` that `show` lists. A domain you removed and added again has a new token. |
| `error` with `caa_blocked` | A `CAA` record on the hostname or a parent domain does not allow `letsencrypt.org`. | Add `CAA 0 issue "letsencrypt.org"`. LimiLake checks again on its own. |
| `error` with `issuance_failed` | The certificate was not issued within 30 minutes, or could not be renewed. | Check the `_acme-challenge` record, then run `verify`. LimiLake does not retry this on its own. |
| `error` with `ownership_lost` | The `_acme-challenge` record has been gone or changed for 72 hours. | Publish it again, then run `verify`. |
| `add` refuses with `custom_domain_limit_reached` | The Tenant has reached 5 own hostnames or 10 LimiLake subdomains. | Remove a domain you no longer use. |
| `add` refuses with `platform_limit` | LimiLake cannot take another external domain right now. | Contact LimiLake support. |

## Next steps

- [Apps](./apps.md): members Apps, public Apps and their limits.
- [Functions](./functions.md): declare HTTP routes. Read the visitor's address
  with [`limilake.client_address()`](./functions-reference.md#the-client-address).
- [Templates](./templates.md): start a new App from a template.
- [CLI command reference](./cli-reference.md): every `limilake workspace domain` flag.
