Osy#betaRun it on Osyrin: osyrin.com

Reference / Stdlib

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

App.BaseUrl · App.Domain · App.Slug

`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.

preview1 example compiled by CIstdlibappaddressdomain

Summary#

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

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#

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#

Which address it is#

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#

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#

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#

Related

The standard library — and where each call runs

The pure standard library, and the one fact about it that changes how your app feels: 271 of its 396 methods run in the…

Http.*

Make an outbound HTTP call to a URL you build at runtime — a webhook, a third-party API, a discovered endpoint…

Every language's page, for a search engine — hreflang, canonical, sitemap

An app that speaks more than one language tells search engines where each page lives in each one, with nothing written…

Serving an app at your own domain

A custom domain serves one of an app's environments at a name you own, like app.example.com. `osyrin app domain add`…