# App.BaseUrl — the address your app is known by, for links in mail and background work

> `App.BaseUrl` is the scheme and host your app answers at, with no trailing slash — what you put in front of a path to make a link that works outside the page: in an email, a webhook payload, a sitemap. During a request it is the address that request arrived at. Where no request says (a workflow's mail, a scheduled job), it is the app's primary custom domain when that domain is verified, else its one verified custom domain, else its platform address.

<!-- id: stdlib-app-address · area: stdlib · stability: preview · html: https://osysharp.com/reference/stdlib/app-address/ -->

## Summary        {#summary}

A link that leaves the page — in an email, a webhook, a sitemap — needs the app's whole address, not a path:

```osy title="a link a background job can mail" test app=stdlib-app-address
entity Article {
  [MaxLength(120)] string Slug;
  security { allow read when IsAuthenticated; }
}

string LinkTo(Article a) { return App.BaseUrl + "/help/" + a.Slug; }
```

`App.BaseUrl` is `https://` and the host, with no trailing slash, so a path that starts with `/` joins it cleanly.

## Signature      {#signature}

```osy syntax
string App.BaseUrl   // "https://help.example.com" — scheme and host, no trailing slash
string App.Domain    // the platform's own domain apps are served under
string App.Slug      // the app's own name in its platform address
```

## Description    {#description}

### Which address it is        {#which}

**During a request**, `App.BaseUrl` is the address that request arrived at — a person on your custom domain gets links
on your custom domain, and a person on the platform address gets links there.

**Where no request says** — a workflow sending mail, a scheduled job, a webhook delivery — it is, in order:

1. the app's **primary** custom domain, when that domain is verified for the environment doing the work;
2. else the environment's **one** verified custom domain;
3. else the app's **platform address**.

Several verified domains and none marked primary keep the platform address: picking one would put your links on a
domain you may be retiring. Marking one primary (on Osyrin Cloud, **Make primary** on the application's Domains tab)
settles it, and a primary domain that stops verifying gives way to the next answer until it verifies again.

### The platform address sends visitors to your domain        {#redirect}

Once the custom domain an environment is known by has its certificate, a browser opening the platform address is
redirected to the same page on that domain. So `App.BaseUrl` during a page visit is your domain however the visitor
arrived, and a link you mailed before the domain existed still lands on it. Webhooks and API calls to the platform
address are served there as before and are not redirected — during such a request `App.BaseUrl` is the platform address.

### Read each time        {#each-time}

It is answered when it is read, not when the app starts, so a domain verified, made primary or removed while the app
runs is what the next mail links to. Nothing to restart.

## See also       {#see-also}
- [Http.*](https://osysharp.com/reference/http/facade/) — calling out to other hosts
- [Every language's page, for a search engine — hreflang, canonical, sitemap](https://osysharp.com/reference/i18n/search-engines/) — a sitemap built on `App.BaseUrl`
- [Serving an app at your own domain](https://osysharp.com/reference/zones/custom-domains/) — adding a domain, its records, and what changes once it has a certificate
- [The standard library — and where each call runs](https://osysharp.com/reference/stdlib/index/) — the rest of the standard library
