Skip to content

Project addresses

A project-addresses domain gives projects their own addresses under one domain you own. With gallery.example.app, a project called gallery is served at gallery.example.app, as well as at gallery.leafcloud.app.

In the API and the JSON output of leaf domains, this kind of domain is called a platform domain.

Dashboard: open Domains, choose Add domain, then choose Give projects their own addresses. Pick every project, or choose the projects that should get an address.

CLI, every project of the account, including projects you deploy later:

TerminalTerminal windowbash
leaf domains add example.app --project-addresses --all-projects

CLI, only some projects:

TerminalTerminal windowbash
leaf domains add example.app --project-addresses --project portfolio --project docs

API: POST /v1/domains with "kind": "platform". Set "auto_include": true for every project, or give "projects" as a list of {"project": name, "label": label} for chosen ones. label is optional and defaults to the project’s own label.

The command prints the DNS records to create. Add them, then follow Status and checks. The records are in Records to add.

Every project (--all-projects)Chosen projects (--project)
Who gets an addressEvery project on the accountOnly the projects you list
New projectsGet an address at their first deployDo not get one until you add them
DashboardSwitch on Automatically include every project, including new onesLeave it off, and choose the projects on the domain’s page
CLIleaf domains projects <domain> --all-projects onleaf domains projects <domain> --include <project>

Turn either mode on or off later:

TerminalTerminal windowbash
leaf domains projects example.app --all-projects off # only the projects that have an address now keep one
leaf domains projects example.app --all-projects on # every project gets an address
leaf domains projects example.app --include shop # add one project
leaf domains projects example.app --exclude docs # remove one project's address

Turning automatic inclusion off keeps every address a visitor uses. It lists the projects that had one.

A project’s label is the first part of its address. The label of gallery on example.app is gallery, so its address is gallery.example.app. Each label is unique on its domain. If a label is taken, choose another one:

TerminalTerminal windowbash
leaf domains projects example.app --label gallery=photos

The label changes the address at once. The old address stops, and the new one starts.

API: PATCH /v1/domains/{domain}/projects/{project} with {"label": "photos"}.

A project-addresses domain can also serve the bare domain (example.app) and its www form. Each one is a project, a redirect, or off. Set them with:

TerminalTerminal windowbash
leaf domains root example.app --serve portfolio
leaf domains root example.app --redirect https://www.example.app
leaf domains www example.app --serve portfolio
leaf domains www example.app --off

Only a project that has an address on the domain can be served on the root or www address. A project must also have a live deploy.

API: PATCH /v1/domains/{domain} with {"root": {"mode": "serve", "project": "portfolio"}}, {"www": {"mode": "redirect", "redirect_to": "https://www.example.app"}} and so on. The www label is reserved, so no project can use it as a label.

Each of these addresses needs its own record at your DNS provider. leaf domains show lists them. The root record is a CNAME at the domain itself, which many providers do not allow. See DNS providers.

A project’s address on the domain can be switched off without touching the project:

  • In the dashboard, switch the project’s address off with the switch for that domain, on the project’s page or on the domain’s page.
  • With the CLI, leaf domains projects <domain> --exclude <project>.
  • With the API, PATCH /v1/sites/{name} with {"platform_domain": false} turns off the project’s address on the account’s first automatic domain.

When it is off, <project>.example.app stops being served. The project’s <project>.leafcloud.app address keeps working. Switch it on again at any time to publish the project’s current deploy there.

TerminalTerminal windowbash
leaf domains remove example.app

Removing the domain unpublishes every project address on it at once. Projects and their leafcloud.app addresses stay. You can add the domain again later.