@workflow/web
v5.5.0
Published
Workflow Observability UI
Readme
@workflow/web
Observability Web UI Package bundled in the Workflow SDK.
Self-hosting
While this UI is bundled with the Workflow CLI, you can also self-host it.
There are three approaches:
- Run
npx workflow web --noBrowseron a server - Run the published
@workflow/webpackage's server directly - Mount
createWorkflowWebHandler()from@workflow/web/handlerin your own server
All options require the environment to be configured with the right environment variables for the World you're using. Anyone the UI lets in can read every run, and, unless it is read-only, cancel, recreate, re-enqueue and wake runs and resume hooks. Every user shares the backend credentials the server is configured with.
Who can reach it
By default the UI serves loopback clients only: the client's socket address must be loopback (when the server knows it), and the Host header must name localhost, a *.localhost name, 127.0.0.1 or [::1]. kubectl port-forward and a browser on the same machine work; a request from any other machine gets a 403. A port published from a container (docker run -p) arrives from the container network's gateway, not loopback, and gets a 403 as well. To serve other clients, set WORKFLOW_WEB_AUTH:
jwt: every request must carry a JWT, in a header or a cookie, signed by a key in your JWKS. Use it behind a reverse proxy or another application's server that attaches its own token.oidc: users sign in with your OpenID Connect provider (authorization code flow with PKCE), and get an encrypted session cookie.none: no authentication. Only for a deployment that sits behind access control of its own, such as a VPN or an authenticating proxy.
A misconfiguration (an auth variable without WORKFLOW_WEB_AUTH, a missing required setting, a malformed value, an OIDC discovery document that can't be read or names another issuer) stops the server from starting.
When the UI is embedded in a server that does not expose the client's socket address on the Request (srvx-based servers such as Nitro v3 do), the default falls back to the Host header alone, which a client that reaches the server directly can set. Configure WORKFLOW_WEB_AUTH for any embedded UI reachable from other machines.
Allowed host names
To protect against DNS rebinding, the server rejects requests whose Host header is not localhost, a *.localhost name, or an IP address. If you reach the UI under a domain name (for example behind a reverse proxy), list it in WORKFLOW_WEB_ALLOWED_HOSTS or pass --webAllowedHosts to the CLI: comma-separated, .example.com matches the domain and its subdomains, and * disables the check. Cross-origin POST requests are rejected as well, unless their origin is one of these names. A proxy that forwards the browser's Origin while sending its own Host needs the browser-facing name listed here.
Option 1: Run with the CLI
npx workflow web --noBrowser --webAllowedHosts workflow.example.comThis will start the web UI on the default port 3456. The CLI's server reads the same WORKFLOW_WEB_AUTH* variables.
Option 2: Run the published @workflow/web package
The published @workflow/web package contains a prebuilt build/ directory and a standalone server entry point, server.js.
npm i @workflow/web
PORT=3456 WORKFLOW_WEB_ALLOWED_HOSTS=workflow.example.com node node_modules/@workflow/web/server.jsWORKFLOW_WEB_BASENAME=/workflows serves the UI under /workflows instead of the root, for a proxy that forwards only that prefix without rewriting it.
Option 3: Mount the handler
import { createWorkflowWebHandler } from '@workflow/web/handler';
const handler = await createWorkflowWebHandler({
basename: '/workflows',
allowedHosts: ['workflow.example.com'],
// Optional: replaces the WORKFLOW_WEB_AUTH* variables.
auth: {
mode: 'jwt',
issuer: 'https://issuer.example.com',
audience: 'https://workflow.example.com',
jwksUrl: 'https://issuer.example.com/.well-known/jwks.json',
},
});
// handler: (request: Request) => Promise<Response>, for every path under /workflowsBy default the handler builds its own World from WORKFLOW_TARGET_WORLD and that World's variables. Pass world (an instance, or a function returning one) to use your application's World instead, for example one whose Postgres pool authenticates with rotating credentials. A process has one: every dashboard in it shares it.
The UI's browser code calls <basename>/api/rpc and <basename>/api/stream/:id on the origin it was loaded from, so a proxy in front of it must forward every path under the basename, and attach its token to each request.
Authentication settings
auth on createWorkflowWebHandler() and startServer() takes the same settings in camelCase (issuer, jwksUrl, allowedEmails, ...), plus an authorize(claims, { access }) callback; when it is given, the variables are ignored. Lists are comma-separated.
| Variable | Modes | Default | Meaning |
| --- | --- | --- | --- |
| WORKFLOW_WEB_AUTH | | unset: loopback clients only | jwt, oidc or none |
| WORKFLOW_WEB_READ_ONLY | all | false | 1/true: refuse cancel, bulk cancel, recreate, re-enqueue, wake up, resume hook and reading hook tokens, and leave hook tokens out of every response |
| WORKFLOW_WEB_ALLOWED_HOSTS | all | none | Host names besides loopback and IPs (see above) |
| WORKFLOW_WEB_BASENAME | all | / | Mount path of server.js |
| WORKFLOW_WEB_AUTH_ISSUER | jwt, oidc | required | Expected iss; in oidc, also where discovery is read from |
| WORKFLOW_WEB_AUTH_ALGORITHMS | jwt, oidc | RS, PS, ES 256/384/512 and EdDSA | Accepted signing algorithms; HS* and none are refused |
| WORKFLOW_WEB_AUTH_CLOCK_TOLERANCE | jwt, oidc | 5 | Seconds of skew accepted on exp, nbf, iat (0 to 300) |
| WORKFLOW_WEB_AUTH_AUDIENCE | jwt | required | Accepted aud values |
| WORKFLOW_WEB_AUTH_JWKS_URL | jwt | required | The issuer's JWKS; https, or http on localhost |
| WORKFLOW_WEB_AUTH_TOKEN_HEADER | jwt | authorization | Header carrying the token: Bearer <token>, or the bare token in a custom header |
| WORKFLOW_WEB_AUTH_TOKEN_COOKIE | jwt | none | Cookie carrying the token when the header is absent |
| WORKFLOW_WEB_AUTH_DISCOVERY_URL | oidc | <issuer>/.well-known/openid-configuration | Discovery document |
| WORKFLOW_WEB_AUTH_CLIENT_ID | oidc | required | OAuth client ID, and the ID token's expected aud |
| WORKFLOW_WEB_AUTH_CLIENT_SECRET | oidc | none (public client, PKCE only) | Sent with client_secret_basic, or client_secret_post when that is all the provider supports |
| WORKFLOW_WEB_AUTH_REDIRECT_URI | oidc | required | Public URL of <basename>/_auth/callback, as registered with the provider |
| WORKFLOW_WEB_AUTH_SCOPES | oidc | openid email profile | Space- or comma-separated; openid is always added |
| WORKFLOW_WEB_AUTH_SESSION_SECRET | oidc | required | At least 32 characters; comma-separated for rotation (the first encrypts, all decrypt) |
| WORKFLOW_WEB_AUTH_SESSION_MAX_AGE | oidc | 28800 (8 hours) | Seconds a sign-in lasts (60 to 2592000) |
| WORKFLOW_WEB_AUTH_COOKIE_NAME | oidc | __Host-workflow_web_session | workflow_web_session when cookies aren't Secure |
| WORKFLOW_WEB_AUTH_COOKIE_SECURE | oidc | true, unless the redirect URI is http://localhost | Can't be false with an https redirect URI |
| WORKFLOW_WEB_AUTH_ALLOWED_SUBJECTS | jwt, oidc | none | Exact sub values allowed |
| WORKFLOW_WEB_AUTH_ALLOWED_EMAILS | jwt, oidc | none | Emails allowed, only with email_verified: true |
| WORKFLOW_WEB_AUTH_ALLOWED_DOMAINS | jwt, oidc | none | Email domains allowed (exact, not subdomains), only with email_verified: true |
| WORKFLOW_WEB_AUTH_ALLOWED_GROUPS | jwt, oidc | none | Groups allowed |
| WORKFLOW_WEB_AUTH_GROUPS_CLAIM | jwt, oidc | groups | The claim holding groups |
| WORKFLOW_WEB_AUTH_REQUIRED_CLAIMS | jwt, oidc | none | JSON object: each claim must have one of the values, e.g. {"environment":["production"]} |
| WORKFLOW_WEB_AUTH_WRITE_GROUPS | jwt, oidc | none (everyone allowed in can write) | Only these groups get write access; everyone else allowed in gets read access |
Without any allowlist, every token or account the issuer signs for the audience or client is allowed in. With several, matching any one of them is enough; required claims must all match.
In oidc mode the UI serves <basename>/_auth/login, <basename>/_auth/callback and <basename>/_auth/logout. A page load without a session redirects to the login and comes back to the same page; an API call gets a 401. Changing the allowlists or the session secrets signs everyone out.
Read-only access refuses changes on the server with a 403; the buttons stay visible and show the error when used.
See Self-hosting the web UI for every setting, a reverse-proxy example, and the Postgres World's Kubernetes setup.
Configuration (environment variables)
The UI reads configuration on the server via environment variables.
Vercel (remote observability):
WORKFLOW_TARGET_WORLD=vercelWORKFLOW_VERCEL_TEAMWORKFLOW_VERCEL_PROJECTWORKFLOW_VERCEL_ENV(optional; defaults toproduction)VERCEL_WORKFLOW_SERVER_URL(optional; routes all Vercel analytics and primary-storage requests to a different workflow-server deployment)
Local (filesystem-backed observability):
WORKFLOW_TARGET_WORLD=localWORKFLOW_LOCAL_DATA_DIR(absolute path to the workflow data dir, e.g./path/to/project/.workflow-data)WORKFLOW_MANIFEST_PATH(optional; enables the Graph tab)
Postgres:
WORKFLOW_TARGET_WORLD=postgresWORKFLOW_POSTGRES_URL
For a complete list and CLI flags, see npx workflow inspect --help and npx workflow web --help.
If you're deploying this to Vercel, setting WORKFLOW_TARGET_WORLD to vercel is enough
for the server to infer your other project details at runtime. Note that observability will be scoped to the project and environment you're deploying to.
