Skip to content

Going to production

Your development instance is ready at once; the production instance needs a few things only you can provide. Work through the list in order. Every step links to the page that explains it.

A production instance serves sign-in from a subdomain of your own site, such as accounts.example.com. In the dashboard choose Go to production, enter the host and add the CNAME record it shows. The instance works once the domain is active. Several later steps (the social redirect URL, the live keys’ host) depend on it. See Custom domains.

Replace the development keys with the production instance’s: pk_live_… in your frontend and sk_live_… on your server, both under API keys of the production instance. The secret key is shown once. Development keys (pk_test_…, sk_test_…) belong to the development instance and never see your production users. See Instances and environments.

SDK Where
Next.js NEXT_PUBLIC_ZAUTHA_PUBLISHABLE_KEY and ZAUTHA_SECRET_KEY
Node.js publishableKey option and ZAUTHA_SECRET_KEY
ASP.NET Core Zautha:PublishableKey and Zautha:SecretKey (Zautha__PublishableKey, Zautha__SecretKey)

In Next.js, NEXT_PUBLIC_ZAUTHA_PUBLISHABLE_KEY must be set when you run next build, not only when the server starts: the build reads it to prerender. A Docker image built without it fails to build, and one built with the development key shows that key in production. If you build once and deploy the same image with different keys, use <ZauthaProvider dynamic>: it reads the key per request, so the build needs none.

Your server accepts a session token only when it was issued for one of your own origins (the token’s azp). List every origin your app is served from, exactly (https://app.example.com, no path or trailing slash):

  • Next.js: the ZAUTHA_AUTHORIZED_PARTIES environment variable, comma-separated. Leave it unset while developing on localhost. See @zautha/nextjs.
  • Node.js and Express: the authorizedParties option of zauthaMiddleware, authenticateRequest and verifyToken. See @zautha/backend.
  • ASP.NET Core: options.AuthorizedParties. See Zautha.AspNetCore.

On an origin missing from the list every request is signed out.

Every https origin on your domain and its subdomains is already an allowed origin of the production instance. List any other origin your pages are served from in Auth settings; a production instance accepts https origins only.

A production instance uses your own OAuth app at each social provider; Zautha’s shared apps are for development only. For each provider you offer, create the app, register the instance’s redirect URL and enter the credentials in Social connections: Social providers, with a page each for Google, GitHub, Microsoft, Discord, GitLab and Apple. Zautha refuses to enable a provider on a production instance until its own credentials are complete.

Production sign-up, and sign-in after repeated failures, need a Cloudflare Turnstile check that the SDK runs in a frame from https://accounts.zautha.com. If your pages send a Content Security Policy, allow it:

Content-Security-Policy: frame-src https://accounts.zautha.com

(add it to the frame-src you already have). Without it the check cannot load and the call fails with a ZauthaCaptchaError, usually with code timeout (see @zautha/js). Sites that only send users to the instance’s hosted login have no sign-in on their own pages and need nothing. See Bot protection.

Webhook endpoints are per instance, so add the production endpoint again on the production instance’s Webhooks page, with an https URL on a public host, and give your server that endpoint’s signing secret (whsec_…). A development endpoint never receives production events. See Webhooks.

Allowlist and blocklist are per instance too, off by default. If you restrict who can sign up, set the lists on the production instance. See Sign-up restrictions.

  • Test identities: addresses ending in +zautha_test and the code 424242 work on development instances only. On production they are ordinary addresses that receive real mail.
  • Users, settings, OAuth clients and signing keys: an instance shares nothing with the other one, so settings you made in development (sign-in options, branding, organizations) are made again in production.