Building an nFocus site
Each organization's website is either a Duda website (see the Duda guide) or an nFocus site. The public registration portal itself serves an nFocus site, so the organization's pages and the registration flow (catalog, cart, forms, checkout, account) are one app with one look. This guide covers what the public portal needs from the API to serve one.
Which portal a request is for
An nFocus site is served at two kinds of address:
- its portal path,
{portal}/{clientToken}/{orgToken}/, always; - its domains: a platform address (
{prefix}.{platform suffix}) and the organization's own domains, once they are active (see Organization site, "An nFocus site's domains").
At the portal path, the path names the portal. On any other host, ask the API which portal that host serves:
Which portal a domain serves
GET https://api.nfocus.solutions/v1/sites/by-domain?domain=riverbend-central.sites.example.test → 200 OK, JSON
curl
curl -s 'https://api.nfocus.solutions/v1/sites/by-domain?domain=riverbend-central.sites.example.test'JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/sites/by-domain?domain=riverbend-central.sites.example.test');
const data = await response.json();C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/sites/by-domain?domain=riverbend-central.sites.example.test");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();- 200: the host is an active domain of an nFocus site.
clientTokenandorgTokenname the portal for every/v1/portals/…call;portalPathis its path on the public portal. - 404
site-not-found: the host serves no website. Answer 404 too. primaryDomainandisPrimary: when the host isn't the primary address, redirect to the same path onprimaryDomain(permanently, 301).- Caching: the answer may be cached for 60 seconds (
Cache-Control: public, max-age=60). A domain that becomes active, or is removed, can take that long to change.
GET …/config says whether the portal is also the organization's website: website.provider is nfocus,
website.templateKey is the published template (null until the site first publishes), and website.primaryUrl is its
primary address (the primary domain, else the portal path). For a Duda website it is duda with the Duda website's
address. A portal with neither has no website. The pages themselves come from GET P/website (see Building an nFocus
site from a template).
Sign-in
- On a domain: use the site's own sign-in client,
signInClientIdfrom the lookup (site-{clientToken}-{orgToken}), with the redirecthttps://{host}/callback. Only the site's active domains are registered as its redirects, and the client signs families in only at its own portal. - At the portal path: use the multi-tenant
trax-olrclient withportal={clientToken}/{orgToken}, as on any portal page.
Both use authorization code with PKCE on the API's hosted sign-in pages (see Authentication and keys). An nFocus site needs no site key: the public portal calls the API without one.
What hosting does
The API decides which domains serve; it runs no DNS and issues no certificates. Hosting the public portal means:
- DNS: each custom domain needs a CNAME (or A records) to the front end, which the API checks: every address the
name resolves to must be the front end's. The organization also publishes a TXT record that proves it owns the
domain (
_trax-verify.{domain}; see Organization site, "An nFocus site's domains"). The platform address is a wildcard the platform's DNS points at the front end. - TLS: certificates on demand for each custom domain, with the lookup as the check ("ask"):
GET /v1/sites/by-domain?domain={host}answering 200 means issue one. The platform address uses a wildcard certificate. - Routing: every nFocus host goes to the public portal front end, which asks the lookup and redirects non-primary domains to the primary one.