A domain for one project
Use a domain for one project when one site should answer at a domain you own, such as shop.example.com. The project’s <project>.leafcloud.app address keeps working next to it.
Add a domain
Section titled “Add a domain”Dashboard: open Domains, choose Add domain, then choose For one project. Enter the domain and pick the project.
CLI:
leaf domains add shop.example.com --project portfolioAPI: POST /v1/sites/{name}/domains with the domain in the body:
{"domain": "shop.example.com"}--wait keeps the command running until the domain is live, or stops when it fails:
leaf domains add shop.example.com --project portfolio --waitThe command prints the DNS records to create. Add them at your DNS provider, then see Status and checks.
The bare domain and www
Section titled “The bare domain and www”When you add example.com, LeafCloud also adds www.example.com, and the reverse. The two addresses form a pair. The pair shares one ownership record, and you add and remove them together.
What each address does depends on whether the project already has a primary address:
- No primary yet. The address you typed becomes the primary, and it serves the project. Its partner is set to a redirect to it automatically, in the same step. Typing
example.commakes the bare domain the primary andwwwa redirect to it. Typingwww.example.commakeswwwthe primary and the bare domain a redirect to it. You do not need a separate command for the redirect. - A primary already exists. Both addresses serve the project. Neither one redirects. Use the commands below if you want one of them to redirect.
A redirect answers 308 Permanent Redirect and keeps the path and the query string. A visit to example.com/about?x=1 goes to https://www.example.com/about?x=1 with a 308 status. Browsers and search engines treat it as a permanent move.
To choose the primary when the project has none yet, send "primary": "root" or "primary": "www" when you add the pair through the API. The CLI has no flag for this. With the CLI, add the pair, wait until it is live, then make the other address primary with the commands below.
You can change how any address is served later:
leaf domains primary www.example.com # make it the project's primary address; it must be liveleaf domains redirect example.com # send visitors to the primary addressleaf domains serve example.com # serve the project here too, instead of redirectingThe primary address cannot be changed to a redirect or a serve directly. Make another live address the primary first.
API: POST /v1/domains/{domain}/route with {"route": "primary"}, {"route": "serve"} or {"route": "redirect"}.
Several domains for one project
Section titled “Several domains for one project”A project may have several domains of its own, such as www.shop.com, shop.in and store.shop.com. Add each one with leaf domains add, or from the project’s page in the dashboard. Each domain has its own records and its own status.
There is a limit per project. See Limits.
Remove a domain
Section titled “Remove a domain”leaf domains remove shop.example.comThe command asks you to type the domain, unless you pass --yes. Removing one half of a www pair removes both halves. The project keeps its leafcloud.app address and its other domains. If you remove the primary address, another live address becomes the primary.
The certificate for a removed domain stops renewing. You can add the domain again later, on this project or another one.
Related
Section titled “Related”- Project addresses for giving many projects an address under one domain.
- DNS providers for a root domain at a provider that cannot point it at LeafCloud.
- Troubleshooting.