Skip to Content
Docs

Site Workers

Bind a Site to an application image, verify deployment, and configure authentication origins, domains, and logs.

A Site Worker uses the platform-managed managed-site-worker template to run an application image with a Site. The Site holds identity and optional authentication configuration; its source repository and application image are managed independently. The Worker binds the Site and image together.

Understand the Site Binding

Keep these deployment selections distinct:

Selection What It Controls
Application image Your application code and HTTP server, pinned to an image digest when saved. The template's IMAGE option selects this image.
Managed template version The platform-provided serving and authentication runtime, selected with managed-site-worker:<version>.
Saved Worker configuration The selected template, application image, Site binding, and runtime settings. Saving an update creates a new Worker configuration version and starts deployment.
Site configuration version The Site record selected by SITE_ID. Use an ID to follow its latest version, or id#version to pin a saved version.

For refresh behavior, including Auth Profile settings that refresh even when the Site is pinned, see Apply Site Configuration Changes.

Find available managed template versions in the console's Managed worker fields. Review runtime compatibility before selecting a different version.

The template runs a public gateway beside your application. The application serves plain HTTP privately; the gateway handles public traffic and supplies authentication configuration and visitor identity. It does not inject a platform SDK or tenant credentials into the application. This template uses the Site application's Dockerfile and HTTP server, rather than the handler adapters, worker.json, or .worker-image packaging used by other managed templates.

Deploy and Verify

Follow the Quickstart for concrete create commands and Deploy a Visible Change for an application update. A build from the application repository supplies IMAGE; for a prebuilt image, set that template option instead. Keep the managed template selection when updating an image. See Workers CLI Reference for other deployment operations.

The template supplies gateway health and readiness checks. Readiness requires the gateway to load the Site configuration and the application to accept connections. Your application does not need a custom /health route.

After creating, starting, or updating the Worker:

  1. Open Workers in the intended tenant and select the Site Worker.
  2. Inspect instances and readiness under Deployment. A running status alone does not confirm that the application works.
  3. Under Deployment, copy the Public Worker URL and open it. Verify the expected content or application change.
  4. For an authenticated Site, test signed-out access to protected routes, sign in with a Site User, and test access again. Sign out and confirm that protected routes require sign-in again. For a public Site, confirm the intended content loads without sign-in.

Authentication and Browser Origins

When the Site has an Auth Profile, the gateway validates visitor sessions and resolves Site Users. Application code controls which routes require sign-in and what each user can access.

With Managed Stytch, Contextual registers the Worker's URL and verified custom-domain origins, including sign-in redirects, when you create, start, restart, or update the Worker. If a running Site switches from no authentication or BYO Stytch to Managed Stytch, restart or update its Worker, then verify hosted access.

With BYO Stytch, the project owner must register those origins and redirects in their own project, including <origin>/sign-in?redirect={}. See Choose an Authentication Provider for provider setup.

Use a Custom Domain

A custom domain belongs to the Worker, independently of the Site. Workers using the same Site can have different domains.

Follow Custom Domains to set, verify, change, or remove the hostname. For an authenticated Site, complete origin registration and test sign-in, sign-out, and protected routes at the custom domain.

Install a Site Through a Service

A Service can install a Site and its Auth Profiles in other tenants. The Site Worker is not part of the Service: deploy it in each tenant after the Service installs the Site.

  1. Add the Site and the Auth Profiles it references to the Service Definition. Site Users are not part of a Service; create them in each target tenant.
  2. Install or update the Service in the target tenant.
  3. With a CLI configuration for the target tenant, create the Site Worker from the application root as in the Quickstart, with SITE_ID set to the installed Site's ID. --build . pushes the application image to that tenant's image host.
  4. Verify the deployment in the target tenant.

A repository's GitHub workflows deploy to the one tenant named by CONTEXTUAL_ORGANIZATION. Deploy to other tenants with the CLI. See Coordinate Worker Deployments and Service Releases for ordering and recovery.

Settings and Logs

Site Workers require at least one replica. Use Worker Settings for size, replicas, and encrypted environment variables, and Secrets and Configuration Files for file-based configuration.

Requests to a Site Worker’s public URL have a default limit of 1 MiB for the entire request body, and you can raise that limit by setting the Worker environment variable BODY_SIZE_LIMIT as described in HTTP Workers.

Read application and gateway container output with the Worker logging commands. In the Astro Site application, Astro.locals.logger methods are asynchronous wrappers around server-side console output; await their calls. Browser console messages appear in browser developer tools.