Vercel preview deployment
This is the first hosted deployment path for apps/web. It is intentionally narrow: get a live Vercel URL for a pull request when someone asks for one, and keep unsafe public states locked. Production hardening belongs here only after an explicit follow-up issue owns it.
Preview deploys are manual. Two independent paths could create one, and both are closed:
- GitHub Actions. Same-repository PRs selected with
ci:browsersorci:visualsdeploy an exact-head preview for browser/backend acceptance throughBaseline Checks. Other previews are requested through On-demand preview deploy. - The Vercel Git integration.
apps/web/vercel.jsonsetsgit.deploymentEnabledto{ "**": false, "main": true }, so pushing a commit to any branch other thanmaincreates no automatic Vercel deployment.mainis listed explicitly because Vercel deploys a branch when it matches at least onetruerule, and production hosting depends on the Git integration formain.
Two caveats on the Git-integration control. Vercel reads vercel.json from the commit being pushed, so a branch that does not yet carry this setting still auto-deploys until it picks the change up from main. And git.deploymentEnabled governs the Git integration only; it does not affect vercel deploy from the CLI, which is how the on-demand workflow and staging-deploy.yml deploy.
Dashboard-side state is not verifiable from this repository. If the Vercel project also has preview deployments or branch tracking configured in its dashboard settings, reconcile them with the setting above so the in-repo file stays the source of truth.
Vercel project
Create or import one Vercel project for this repository:
- repository:
BASIC-BIT/VRDex - root directory:
apps/web - framework preset:
Next.js - build command:
pnpm build:vercel - install command: Vercel default pnpm workspace install
- output directory: Vercel default for Next.js
apps/web/vercel.json records the app-local build command so dashboard and CLI builds use the same deployment validation step.
Run Vercel CLI commands from the repository root once the project root directory is set to apps/web; running from apps/web will make Vercel resolve the app root twice.
Repository variables and secrets
Current recommendation: keep repository Actions variables and secrets reproducible through checked-in workflows/docs first, and provider APIs or CLI scripts where practical. Secret values still belong in GitHub/Vercel/Convex secret stores, but their names, scopes, and recreation path should be documented here.
The on-demand preview workflow deploys a Vercel preview only when all three repository secrets exist:
VERCEL_TOKENVERCEL_ORG_IDVERCEL_PROJECT_ID
The workflow can also deploy a matching Convex preview backend when this optional repository secret exists:
CONVEX_DEPLOY_KEY_PREVIEW
If any of the three Vercel secrets is missing, the run fails and names the missing secrets instead of deploying partially. Because the preview is requested explicitly, failing loudly is the correct signal; there is no longer a baseline job that needs to stay green before the hosted project is linked.
VERCEL_TOKEN must be a Vercel account access token created from Vercel account settings. The local Vercel CLI session token from auth.json is not accepted by vercel --token in GitHub Actions and should not be stored as this secret.
When CONVEX_DEPLOY_KEY_PREVIEW exists, the workflow creates or updates the
pr-<number> Convex deployment for manual previews, or a run-owned
ci-pr-<number> deployment for acceptance with convex deploy --preview-create before the
Vercel build. It writes only the resulting NEXT_PUBLIC_CONVEX_URL as a step
output. The project preview deploy key remains confined to GitHub Actions and is
never injected into Vercel, written to an artifact, or posted in a PR comment.
The same workflow creates a random, masked persistence-bridge secret for that
single run. It writes the secret to the named Convex preview and injects it only
into the matching Vercel deployment. The bridge exposes only the guarded
dynamic-client persistence mutations needed by DCR and CIMD smoke checks. When
the hosted developer-credential gates are also enabled, a second Convex-side
capability flag permits the same bridge secret to issue client-credentials
access-token records. PR previews do not receive CONVEX_ADMIN_TOKEN; all
broader internal operations remain unavailable from the preview web runtime.
When VRDEX_HOSTED_E2E_AUTH_HELPERS=true and the browser token exists, the
workflow enables the guarded auth helpers with a separate per-preview Convex
secret. VRDEX_HOSTED_E2E_DEVELOPER_CREDENTIALS independently controls the
preview OAuth token bridge. Leaving that switch false does not disable browser
auth acceptance or enable developer-token issuance.
Selected same-repository browser runs require VRDEX_HOSTED_E2E_CLERK_AUTH=true
and both existing VRDEX_HOSTED_E2E_CLERK_PUBLISHABLE_KEY and
VRDEX_HOSTED_E2E_CLERK_SECRET_KEY secrets. They must name the development Clerk
instance already configured in Vercel Preview and the Convex project's preview
CLERK_JWT_ISSUER_DOMAIN default. No Clerk instance or JWT template is created
by this workflow. Missing configuration fails selected coverage rather than
reporting an empty successful run.
Before creating test data, scripts/candidate-preview-acceptance.mjs checks
/api/deployment for the full candidate commit, preview environment, matching
browser and server Convex URLs, and the runner's development Clerk instance.
The existing profile submission suite writes, reads back and cleans up one
isolated profile. Existing auth/session and account suites run on desktop and
mobile with disposable Clerk test accounts and their cleanup helpers.
Screenshot capture follows ci:visuals; browser assertions run with either
selection. Three separate reports preserve each suite's output. The seven-day acceptance
artifact binds the full head, preview origin, both backend URLs, observed time
and actual expected passes. Missing, skipped, empty or failed required coverage
fails acceptance. A final live identity and PR-head refresh rejects stale evidence.
This is a deployed Next production-build preview with a same-branch backend, not a claim about production accounts, worker/provider behavior or real devices. Broadcast retains its separate integrated rehearsal. Production data is not a target. Shared staging remains useful for deployed health, not PR acceptance.
Automatic-build trust boundary
Selecting browser coverage on a same-repository PR authorizes a credentialed build and preview deployment of its latest head. It is a freshness check, not an independent human approval. The existing Vercel account token and Convex preview deploy key stay in Actions; only trusted repository writers and operators should control this path. Forks do not receive private browser credentials or automatic acceptance. No new approval environment is introduced.
On-demand preview deploy
Acceptance and manual previews have separate concurrency groups and Convex
names. A manual request cannot cancel the required lane or rotate its helper
secret. Acceptance serialises per PR instead of cancelling its predecessor. It reuses
one ci-pr-<number> backend across heads and retries. A manual dispatch with
acceptance enabled uses its own manual-accept-pr-<number> backend and
event-scoped group, so it cannot cancel or rewrite PR acceptance.
Historical preview URLs can point at a backend advanced by a later head. Use
the full-head, timestamped run artifact as point-in-time evidence and the latest
run for current acceptance.
Acceptance suppresses the manual PR comments and
unrelated MCP smoke; its deployment and browser results feed PR verification.
CI preview deployments consume the existing project's preview quota. No numeric
cap is assumed here because it is provider/account configuration. After retaining
the run artifacts and confirming that no task uses a closed PR's backend,
reclaim that exact ci-pr-<number> deployment in the Convex
Dashboard's preview deployment controls. Check the run's recorded name and URL
before deletion. Retain its backend while a PR is open; reclaim closed PR previews after active
uses finish. Leave staging, production and manual pr-<number> previews alone.
The installed Convex CLI exposes no preview-deletion command, so this change does
not invent a deletion API or automate reclamation. A quota failure stops the lane;
it does not purchase capacity or fall back to shared staging.
Preview release checklist
- Before merge, retain the current exact-head report and confirm its required browser coverage passed.
- When a PR closes, confirm no active run or operator still uses its CI or manual-acceptance backend.
- Sweep closed PRs in the Convex dashboard and reclaim their exact
ci-pr-<number>andmanual-accept-pr-<number>deployments. Before reclaimingsandbox-pr-<number>, check or retire the sandbox alias. Check the recorded name and URL; leave production, staging and ordinary manual previews alone.
The preview deploy implementation is reused by selected same-repository PR browser runs. Two workflows also expose manual requests:
.github/workflows/vercel-preview-comment.ymllistens forissue_commentand dispatches the deploy when a pull request comment contains@vrdex previewor/vercel-preview. It requires anauthor_associationofOWNER,MEMBER, orCOLLABORATOR, and refuses non-open pull requests. Fork heads are allowed; see Fork pull requests..github/workflows/vercel-preview-deploy.ymlperforms the deploy. Its only triggers areworkflow_dispatchandworkflow_call, and is also called byBaseline Checksfor selected same-repository PRs. Theworkflow_callinterface exposes adeployment_urloutput so a calling workflow can capture the link.
An unselected preview deploy happens when a person comments @vrdex preview or /vercel-preview on a pull request, or runs the On-Demand Vercel Preview workflow from the Actions tab or gh workflow run. Pushing a commit reruns selected browser acceptance on that exact head. Without browser selection, request a fresh preview explicitly. Manual dispatch can set browser_acceptance=true to require the same acceptance lane.
This path reuses the existing VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID repository secrets and adds no new ones.
The deploy job runs vercel pull, prepares the Convex preview backend and optional smoke fixture, then runs vercel build locally. It uploads the build with vercel deploy --prebuilt --archive=tgz to reduce file-upload requests. The local build embeds the intended Convex URL in the client through NEXT_PUBLIC_CONVEX_URL.
Fork pull requests
The comment trigger deploys fork heads too. The job runs the fork's code with the Vercel token, org and project IDs, and the Convex preview deploy key in scope. The hosted E2E browser token and helper flags are withheld for fork heads and the hosted MCP smoke job is skipped.
The trigger records the head commit it resolved and passes it to the deploy
workflow, which refuses to build if the head has moved since. The deployed SHA
is therefore always the one that was current when the maintainer commented.
A manual Actions-tab or gh workflow run dispatch refuses fork heads unless
the reviewed head_sha input is supplied.
Before commenting @vrdex preview on a fork pull request:
- Read the whole diff, including
pnpm-lock.yaml,package.jsonscripts, anything underscripts/, and.github/. Apostinstallor build script runs with the secrets above. - Read
.npmrcas well. A registry override there redirects everypnpm dlx vercelstep in the job, not just the workspace install. - Note the head commit. The bot comment and the run summary (written by the "Deploy Vercel preview output" step) both name the SHA it deployed; anything pushed after that is unreviewed.
- Remember the Vercel token has no per-project scope. It can deploy or read any project in the team, including the docs site.
- Know that the "Pull Vercel preview environment" step runs
vercel pull --environment=preview, which writes the project's non-sensitive Preview environment values into.vercel/.env.preview.localinside the workspace the fork's build then reads. - After any new push, review again before triggering again.
Hosted MCP preview smoke
.github/workflows/vercel-preview-deploy.yml also runs the Hosted MCP Preview Smoke job after a successful deploy. It targets <deployment-url>/mcp and is fail-closed: it requires both a deployment URL and a same-branch Convex preview backend, so a pass covers data-backed public reads, Dynamic Client Registration, and Client ID Metadata Document authorization.
Because this workflow is dispatched rather than triggered by pull_request, its jobs do not appear as pull request status checks, so a failure cannot turn the pull request red. Two things compensate. The preview comment links the workflow run so the smoke result stays one click from the pull request. And when the smoke fails, the smoke job posts its own Hosted MCP preview smoke failed comment on the pull request and reacts confused to the requesting comment, so a failure is never silent even though the preview deploy itself succeeded. A later passing run rewrites that same comment in place to Hosted MCP preview smoke passed, so a stale failure never outlives the run that cleared it.
Signed-in analytics acceptance
For the analytics rollout check, dispatch vercel-preview-deploy.yml with
browser_acceptance=true, analytics_acceptance=true, and
capture_screenshots=true, pinned to the reviewed open PR head. The analytics
switch defaults false and requires browser acceptance.
That run enables the foundation only in its isolated preview build, with a
synthetic PostHog key, preview category and Limited collection disabled. The
signed-in account suite intercepts PostHog transport and verifies persisted
Off/On, offline-save recovery, stable account identity after reload and a
different identity after switching accounts. Required desktop/mobile results
are checked in candidate-account.json; missing or skipped results fail the
selected lane. candidate-report.json records analyticsAcceptance explicitly.
Both disposable accounts are drained in afterEach, including when the test
body times out, before their Clerk identities are deleted.
This is auth/backend and SDK transport acceptance. It neither changes production settings nor establishes live PostHog ingestion or replay receipt. The link-only preview includes the draft panel and privacy page for review; production copy approval remains separate.
Web environment
Set these in the Vercel project as needed:
NEXT_PUBLIC_CONVEX_URL: optional for a shell-only preview; set to the hosted Convex deployment URL for live backend reads.CONVEX_ADMIN_TOKEN: server-only Convex admin/deploy token for route handlers that call internal Convex functions, currently needed by developer credential inventory API routes.VRDEX_REQUIRE_CONVEX_URL=true: optional; use when previews must fail instead of showing missing-backend states.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYandCLERK_SECRET_KEY: required for any deployment that should accept sign-in. Production builds fail without them; a shell-only preview may omit both.NEXT_PUBLIC_VRDEX_SUBMISSIONS_AUTH_READYis retired — it gated/submitbefore web auth existed, andclerkMiddlewareprotects that route now.NEXT_PUBLIC_POSTHOG_KEY: optional public PostHog project key; BASIC BIT hosted deployments should set this throughinfra/terraform/vercelfor PostHog project447783.NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com: optional PostHog ingestion host; also managed throughinfra/terraform/vercelfor hosted deployments.NEXT_PUBLIC_POSTHOG_DEPLOYMENT_CATEGORY: required for analytics only. One ofdevelopment,preview,stagingorproduction. Terraform assigns production/default preview/custom staging explicitly. Never infer production fromNODE_ENV.NEXT_PUBLIC_POSTHOG_LIMITED_ENABLED: defaults false. Enable after interim-collection eligibility is established. Synthetic local acceptance uses true with an intercepted fake key. Do not copy that setting into production without acceptance evidence.NEXT_PUBLIC_POSTHOG_FOUNDATION_ENABLED: defaults false. Gates the proposed analytics presentation, policy draft and optional browser capture until copy and activation acceptance. BASIC owns activation; recreate the value through checked-in deployment configuration after approval. Local synthetic browser checks explicitly enable it.
Public API, OAuth, and hosted MCP runtime routes also need the server-side
variables inventoried in docs/developers/self-hosting-and-iac.md, including
VRDEX_API_TOKEN_PEPPER, VRDEX_OAUTH_CLIENT_SECRET_PEPPER,
VRDEX_OAUTH_REFRESH_TOKEN_PEPPER, OAuth access-token signing keys, issuer and
resource URLs, and the selected rate-limit backend settings. Keep secret values
in Vercel or the deployment secret store; commit only variable names, scope, and
rotation guidance.
VRDEX_ENABLE_PREVIEW_PERSISTENCE_BRIDGE and
VRDEX_PREVIEW_PERSISTENCE_SECRET are CI-owned preview-only values. Do not set
them in shared staging or production environments.
Do not set VRDEX_ENABLE_PLAYWRIGHT_FIXTURES in Vercel. Fixture profiles are for Playwright-only local/CI preview screenshots and must not be exposed from hosted previews.
Hosted dev/staging E2E targets must set these only on the dev/staging environment, not production:
VRDEX_ENABLE_E2E_HELPERS=trueVRDEX_E2E_BROWSER_TOKEN: same value as the GitHub Actions secretVRDEX_HOSTED_E2E_BROWSER_TOKENVRDEX_E2E_CONVEX_SECRET: non-empty sentinel matching the Convex deployment secret nameVRDEX_ENABLE_E2E_AUTH_HELPERS=true: optional staging-only switch for auth/claim E2E helper routes; keep unset until that flow is intentionally enabledVRDEX_ENABLE_E2E_ADAPTER_HELPERS=true: optional staging-only switch for Discord and VRChat/VRCLinking adapter stubs; keep unset until that flow is intentionally enabledDISCORD_BOT_TOKEN: optional staging-only adapter token when hosted adapter E2E is enabledVRCHAT_PROOF_ADAPTER_BEARER_TOKEN: optional staging-only adapter token when hosted adapter E2E is enabled
Production should keep VRDEX_ENABLE_E2E_HELPERS=false or unset, should keep VRDEX_ENABLE_E2E_AUTH_HELPERS and VRDEX_ENABLE_E2E_ADAPTER_HELPERS unset, and should not set VRDEX_ALLOW_PRODUCTION_E2E_HELPERS unless a human explicitly approves a temporary incident/debug window.
Preview deployment protection must allow unauthenticated reads if the PR preview is meant to be reviewed outside the Vercel dashboard.
Hosted production domain
Locked decision: the hosted BASIC BIT production web app uses the apex domain https://vrdex.net.
Current recommendation: keep both the Vercel project-domain bindings and Route 53 DNS records in infra/terraform/web-domains so production web hosting does not depend on dashboard-only state.
- primary URL:
https://vrdex.net - secondary URL:
https://www.vrdex.net - Vercel project:
vr-dex-web - Route 53 hosted zone:
vrdex.net - Route 53 records:
A vrdex.net 76.76.21.21andA www.vrdex.net 76.76.21.21 - GitHub production smoke variable after DNS is active:
VRDEX_PRODUCTION_SMOKE_BASE_URL=https://vrdex.net
Production deployment status events can still report the generated Vercel deployment URL. Scheduled and push-triggered production smoke should use VRDEX_PRODUCTION_SMOKE_BASE_URL so the stable public domain stays under health coverage.
Hosted staging E2E environment
Locked decision: staging is the shared non-production Vercel custom environment for deployed mutation-backed Playwright health checks.
- target name:
staging - type: Preview custom environment
- branch tracking:
staging - primary URL:
https://staging.vrdex.net - Vercel environment alias:
https://vr-dex-web-env-staging-basicbit.vercel.app - deploy command from the repository root:
pnpm dlx vercel@54.4.1 deploy --target=staging --yes
DNS for staging.vrdex.net is managed in the Route 53 public hosted zone for vrdex.net:
- record:
staging.vrdex.net CNAME 0d67c3b757aeccf9.vercel-dns-016.com - Vercel domain binding: project
vr-dex-web, custom environmentstaging
The staging Vercel environment points at the shared Convex development deployment:
NEXT_PUBLIC_CONVEX_URL=https://scrupulous-corgi-247.convex.cloudCONVEX_URL=https://scrupulous-corgi-247.convex.cloudVRDEX_REQUIRE_CONVEX_URL=trueNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYandCLERK_SECRET_KEYVRDEX_ENABLE_E2E_HELPERS=trueVRDEX_E2E_BROWSER_TOKEN: sensitive value matching GitHub Actions secretVRDEX_HOSTED_E2E_BROWSER_TOKENVRDEX_E2E_CONVEX_SECRET: sensitive value matching Convex dev envVRDEX_E2E_CONVEX_SECRETVRDEX_ENABLE_E2E_AUTH_HELPERS=true: enabled for hosted auth/claim E2EVRDEX_ENABLE_E2E_ADAPTER_HELPERS=true: enabled for hosted adapter E2EDISCORD_BOT_TOKEN: staging-only adapter token matching Convex dev envDISCORD_BOT_TOKENVRCHAT_PROOF_ADAPTER_BEARER_TOKEN: staging-only adapter token matching Convex dev envVRCHAT_PROOF_ADAPTER_BEARER_TOKEN
The staging workflow checks configured Vercel variable names before deployment
without printing their values. It reads the custom-environment listing and
ignores any branch-specific record whose gitBranch metadata is not main.
Every staging deployment requires the Convex
URLs, E2E helper contract, deployment environment, and Redis REST rate-limit
variables listed in STAGING_BASE_ENVIRONMENT_NAMES in
scripts/check-staging-runtime-env.mjs. When repository variable
VRDEX_HOSTED_E2E_DEVELOPER_CREDENTIALS=true, the preflight also requires
CONVEX_ADMIN_TOKEN, the API and OAuth peppers, the access-token signing key,
and the explicit issuer, API, and MCP resource URLs. Missing names fail the
deployment before either Convex or Vercel is mutated; value correctness remains
a provider bootstrap and hosted-smoke responsibility.
Optional defaults such as VRDEX_RATE_LIMIT_REDIS_PREFIX and enforcement
switches such as VRDEX_REQUIRE_CONVEX_URL remain documented but are not
treated as required names by this preflight.
The non-Redis developer runtime bootstrap is reproducible through
pnpm ops:bootstrap-staging-developer-runtime. It requires an ignored env file
containing a deployment-scoped CONVEX_DEPLOY_KEY, a Vercel-linked directory,
and the process-local VERCEL_API_TOKEN. The command generates independent
peppers and an RSA signing key, streams every value to Vercel over stdin, and
prints variable names only:
pnpm ops:bootstrap-staging-developer-runtime -- --apply `
--convex-token-env-file <ignored-token-env-file> `
--linked-vercel-directory <vercel-linked-directory>
This command intentionally does not manage the Redis variables. Those remain
owned by infra/terraform/rate-limit-redis so the Upstash database, endpoint,
token, and Vercel bindings stay one Terraform state boundary.
Convex no longer serves auth callbacks on staging either. The HTTP Actions custom domain https://db.staging.vrdex.net remains verified and scrupulous-corgi-247 selects it as CONVEX_SITE_URL; sign-in runs through the staging Clerk instance.
Current ownership: staging E2E helper variables and non-Redis developer runtime
variables are bootstrap-managed Vercel settings; the checked-in bootstrap above
recreates the developer runtime subset. infra/terraform/rate-limit-redis owns
the shared Redis variables, infra/terraform/web-domains owns production web
domains, and infra/terraform/vercel owns hosted PostHog client variables for
production, default preview, and configured staging custom environment IDs.
Update this document and the matching reproducible owner whenever scopes change,
and never commit secret values.
GitHub Actions uses these repository settings for hosted mutation health:
- variable
VRDEX_HOSTED_E2E_BASE_URL=https://staging.vrdex.net - variable
VRDEX_HOSTED_E2E_EXTENDED_PROFILE_FLOW=true - variable
VRDEX_HOSTED_E2E_AUTH_HELPERS=true - variable
VRDEX_HOSTED_E2E_ADAPTER_HELPERS=true - variable
VRDEX_HOSTED_E2E_DEVELOPER_CREDENTIALS=true: optional; keep unset until staging has the developer token, OAuth app, and OAuth token endpoints under test - secret
VRDEX_HOSTED_E2E_BROWSER_TOKEN
VRDEX_HOSTED_E2E_BROWSER_TOKEN is a staging-only shared secret that authorizes
the bounded E2E helper routes; it is not a user or provider credential. A
repository administrator owns it. Store it only as the GitHub Actions
repository secret and the matching Vercel staging
VRDEX_E2E_BROWSER_TOKEN. Rotate it by replacing the Vercel value first, then
the GitHub secret, and rerun staging deployment. Revoke it by disabling the
hosted auth-helper variable and removing both stored values.
The Staging Deploy workflow runs after Baseline Checks succeeds on main and can also be run manually. It requires these settings:
- secret
CONVEX_DEPLOY_KEY_DEV: deploys functions/schema toscrupulous-corgi-247 - secrets
VERCEL_TOKEN,VERCEL_ORG_ID,VERCEL_PROJECT_ID: deploy Vercelstaging - variable
VRDEX_HOSTED_E2E_BASE_URL: hosted health target, currentlyhttps://staging.vrdex.net - secret
VRDEX_HOSTED_E2E_BROWSER_TOKEN: browser token for hosted E2E helper calls - variable
VRDEX_STAGING_CLERK_JWT_ISSUER_DOMAIN: Clerk Frontend API origin of the development instance backing staging, as a fullhttps://origin. The workflow writes it to Convex asCLERK_JWT_ISSUER_DOMAINbefore deploying functions
Those settings behave differently when absent, and the difference is deliberate. Missing any of the first four means this repository is not configured to deploy staging at all, so the workflow writes a skip summary and exits successfully rather than deploying partially. A missing VRDEX_STAGING_CLERK_JWT_ISSUER_DOMAIN fails the job instead. Staging is configured in that case, and is missing a setting its own auth config requires — convex/auth.config.ts reads it on every hosted deployment and the Convex CLI refuses to push without it. Skipping there would report a green workflow while staging silently stopped updating, which is exactly what left staging serving a pre-Clerk build for three days. See convex-environments.md.
When enabled, the workflow audits the Vercel staging variable-name contract, checks that the issuer matches the Clerk publishable key Vercel is about to serve, writes the issuer to Convex, deploys Convex development functions, deploys Vercel staging, re-checks the issuer against what shipped, and runs pnpm test:e2e:hosted against VRDEX_HOSTED_E2E_BASE_URL.
It then runs pnpm test:e2e:hosted:auth-session, the contract asserting that a Clerk session resolves to a verified Convex identity on the deployment that just went out. That runs here rather than from Deployed Health Checks on the push event, because a push fires while these deployments are still going out — so the contract asserted against the previous deployment and reported that as the health of this one. It is gated on VRDEX_HOSTED_E2E_CLERK_AUTH=true with the Clerk keys present: unset and it skips; set with keys absent and it fails, rather than reporting a passing contract over assertions that never ran. The two Playwright runs write to separate report and results directories so the artifact keeps evidence from both.
Because GitHub Actions snapshots secrets and variables when a run starts, rerun the workflow after completing provider bootstrap.
Hosted production environment
Production Vercel hosting uses the same vr-dex-web project with the production domain https://vrdex.net and Convex production deployment superb-pig-954.
NEXT_PUBLIC_CONVEX_URL=https://superb-pig-954.convex.cloudCONVEX_URL=https://superb-pig-954.convex.cloudVRDEX_REQUIRE_CONVEX_URL=trueVRDEX_ENABLE_E2E_HELPERS=falseor unsetVRDEX_ENABLE_E2E_AUTH_HELPERSunsetVRDEX_ENABLE_E2E_ADAPTER_HELPERSunset
Production must set the same API/OAuth/MCP runtime variables for any enabled developer API, OAuth issuer, or hosted MCP surface.
Convex no longer serves auth callbacks. Clerk hosts sign-in, and CONVEX_SITE_URL on superb-pig-954 stays https://db.vrdex.net for the HTTP Actions the app still uses.
Production auth status, pending cutover:
- Clerk is the sign-in provider. The production Clerk instance needs its own
convexJWT template, its own keys, and its own Google and Discord OAuth credentials pointed at Clerk's callback URLs. - The existing Google and Discord OAuth clients are reused by repointing their redirect URIs at Clerk. Do not delete them — the Discord client is also used by community verification, which is independent of sign-in.
CLERK_JWT_ISSUER_DOMAINon Convex must match the issuer of that template.JWT_PRIVATE_KEYandJWKSare retired; Clerk signs tokens now.- Session lifetime is Clerk's, documented in
docs/backend/auth-sessions.md. The previous 30-day inactivity / 90-day cap contract is not reproduced.
Production authenticated account smoke
The Deployed Health Checks workflow runs the production public route smoke when
VRDEX_PRODUCTION_SMOKE_BASE_URL or a deployment status URL is available. The
authenticated account smoke requires an explicit manual dispatch. Configuring its
secret does not enable authenticated checks on schedules, pushes, or deployments.
Repository settings for the authenticated smoke:
- variable
VRDEX_PRODUCTION_SMOKE_BASE_URL=https://vrdex.net: the stable public domain that matches the captured cookies - secret
VRDEX_PRODUCTION_AUTH_SMOKE_STORAGE_STATE_B64: base64-encoded PlaywrightstorageStateJSON for a dedicated production Clerk test account VRDEX_PRODUCTION_AUTH_SMOKE_PROVIDERis retired. The account page exposes Clerk's management affordance rather than linked-provider labels
The deployment operator owns the test account, state capture, and secret renewal. Use an account without administrative roles, organization memberships, or ownership of real profiles. The repository secret grants that account's browser session; it must contain only the dedicated account's Clerk state. Do not put account passwords, OAuth credentials, Clerk API keys, or sign-in tickets in this secret. Keep production E2E helpers disabled.
To capture or renew the state:
-
Start an isolated browser context and sign in to
https://vrdex.netas the dedicated account. Email sign-in, a linked provider, or an explicitly authorized short-lived Clerk sign-in ticket can establish the session. -
Confirm the expected account on
/account, then export the context's Clerk cookies with PlaywrightstorageState. Include the HttpOnly__clientcookie onclerk.vrdex.net, including any instance-suffixed cookies actually present. App-domain__sessionand__refreshcookies alone do not establish the full client session. Exclude unrelated cookies and browser storage. -
Close the capture context and wait until the captured session JWT expires. Load the exported state in a fresh browser context and run the existing
production-auth.smoke.spec.tsthroughpnpm test:e2e:hosted:auth-smoke, withPLAYWRIGHT_BASE_URL=https://vrdex.net,PLAYWRIGHT_SKIP_WEBSERVERS=true,VRDEX_PRODUCTION_AUTH_SMOKE_MODE=manual-one-shot, and the encoded state inVRDEX_PRODUCTION_AUTH_SMOKE_STORAGE_STATE_B64. Confirm that the authenticated test actually ran and passed. This proves refresh works beyond the captured short-lived JWT. -
Store the verified encoded state as the repository secret. Keep raw state and cookies out of logs, committed files, screenshots, and CI artifacts. Pass the value to the secret manager through a protected input such as stdin.
-
Dispatch the production smoke and inspect the authenticated step's result:
gh workflow run deployed-health.yml --repo BASIC-BIT/VRDex --ref main -f target=production-smoke -f production_auth=true
The workflow fails an explicit authenticated request if the canonical base URL or
secret is missing. Use target=production-smoke for this check; target=all also
runs staging mutation checks. The operator must replace the state when the Clerk
session expires, is revoked, or becomes invalid after configuration changes.
Neither the smoke nor the workflow renews the repository secret.
The smoke checks that /account shows a sign-out control and the sign-in
management affordance. It makes no profile edits or other authored data writes.
Normal authenticated page loading may provision or refresh the test account's
Convex identity row. It does not verify OAuth consent, provider linkage, or the
sign-in method used to obtain the session.
Promoting Production
Vercel's Git integration builds production deployments. Whether it aliases a
new build to vrdex.net depends on provider configuration, so inspect the live
alias for each release. During PR #343, the production deployment was already
aliased before manual promotion.
That is not hypothetical: during the Clerk cutover, Convex production deployed
the Clerk backend while vrdex.net kept serving the pre-Clerk bundle, whose
sign-in called Convex Auth functions the deploy had just deleted. Production
sign-in was broken for hours while every read path returned 200.
Promote with the Promote Production Web workflow:
gh workflow run production-promote.yml -f deployment_url=https://vr-dex-<id>-basicbit.vercel.app
Find the exact intended commit with vercel ls and deployment metadata. Verify
that deployment is Ready and its environment is Production before promotion.
Dispatch is manual on purpose. The preflight can show a build is not obviously broken; it cannot show that releasing it is wanted.
It refuses to promote unless all of the following hold, each corresponding to a way production has broken or nearly broken before:
-
/sign-upreturns 200 — a build predating the auth routes cannot sign anyone in -
/sign-inreturns 200 before its body is inspected — an error document still renders the shared auth layout, so its body would otherwise satisfy the content checks -
the page does not render the auth-unavailable notice — that build was made without Clerk credentials
-
the publishable key decodes to
clerk.vrdex.net— tier alone does not prove tenant, and another tenant'spk_live_key would have Convex reject every token -
/api/deploymentreports, as JSON, the backend identities the running build actually resolved. Each must match production exactly:convexBrowser—NEXT_PUBLIC_CONVEX_URL, what the browser client usesconvexServer—CONVEX_URL ?? NEXT_PUBLIC_CONVEX_URL, the precedenceconvexHttpClient()applies for the API, OAuth, MCP, and account route handlers. It is a separate value, so a build can serve the right data to the browser and the wrong data from its route handlersclerkFrontendApi— decoded from the publishable key, naming the Clerk tenant
Compared as complete URLs, not hosts or origins. Both clients receive the value verbatim, so
http://(whose WebSocket an https origin blocks) and a stray path (whichConvexHttpClientwould target) must both fail. A missing Convex URL is only a build warning, so without this a build with no backend is promotable -
clerk.vrdex.net/v1/environmentreturns 200 — the instance must be able to issue tokens -
that response has
user_settings.actions.delete_selffalse — the promoted build exposes Clerk's profile surface, and VRDex cannot reconcile a deleted identity until #227
Afterwards it compares the ?dpl= deployment id on vrdex.net against the
requested deployment, so an alias that did not move fails rather than passing on
a route check the previous release would also satisfy.
Validation
The Vercel build runs pnpm build:vercel, which executes apps/web/scripts/check-vercel-env.mjs before next build.
The validation fails when:
- Playwright fixtures are enabled.
- Any E2E helper switch is enabled for a production Vercel build.
- A Clerk key is missing: both are required for every production build, and for any build with
VRDEX_REQUIRE_CONVEX_URL=true. - Only one Clerk key is set. Both, or neither — one key alone mounts
ClerkProviderand selectsclerkMiddlewarewith no server-side credential, which fails at runtime rather than falling back to unconfigured auth. - A Clerk key is from the wrong tier: production requires
pk_live_/sk_live_, every other Vercel environment requirespk_test_/sk_test_, so a preview cannot authenticate against the production tenant. - A rate-limit variable is missing or invalid for a production build:
VRDEX_RATE_LIMIT_STOREmust beredis-restorupstash, and the REST URL must be https and not a local backend. NEXT_PUBLIC_CONVEX_URLis invalid.NEXT_PUBLIC_CONVEX_URLpoints at localhost during a Vercel build.VRDEX_REQUIRE_CONVEX_URL=trueandNEXT_PUBLIC_CONVEX_URLis missing.NEXT_PUBLIC_POSTHOG_HOSTis invalid or points at a local backend during a Vercel build.
Live smoke check
After a preview deployment, visit:
/for the public shell/api/deploymentfor Vercel environment and commit metadata (commit,branch,environment)/submitto confirm signed-out users are routed to sign in before writing
The on-demand preview workflow posts an On-demand Vercel preview comment with the preview URL, the /api/deployment URL, and a link to the workflow run that carries the hosted MCP smoke result.
Stable sandbox URL
Use a dedicated browser profile for the sandbox, with a preview Clerk account. Keep your production VRDex session in a separate profile. Clerk scopes its session JWT to the application hostname, but sibling subdomains can still write cookies for the parent domain. See Clerk's session token documentation.
For shared sandbox iteration, push the reviewed commit to codex/sandbox.
In the BITRATE Labs repository, branch protection restricts direct pushes to
BASIC-BIT and applies to admins. It disables force pushes and deletion. Keep
this restriction in place while branch builds use deployment credentials. The
workflow also checks the push sender's GitHub account ID.
When VERCEL_SANDBOX_PROJECT_ID is configured, only this branch can update the
sandbox alias. Pushes queue and use the existing sandbox-shared Convex preview,
so drafts and OAuth grants survive deploys. Before deployment the workflow
verifies the named preview against the pinned Convex URL, independently of the
current alias. A mismatch stops deployment before uploading functions.
git push origin HEAD:codex/sandbox
Check the deployment identity for the expected commit, preview environment, and disabled E2E helpers. The sandbox has its own preview OAuth runtime and reuses its secrets on later pushes. A non-preview build rejects requests for the sandbox hostname.
Use the ordinary PR preview for a separate review deployment. Installations
without a dedicated sandbox project can still request manual PR sandbox mode
with sandbox=true and the exact PR head. That mode recreates its
sandbox-pr-<number> backend, clearing its test data and OAuth grants.
Bootstrap or recover the shared sandbox
- Check the Convex dashboard for the named
sandbox-sharedpreview. If it exists, keep it and record its cloud URL. Only when no such preview exists, use the project preview deploy key in the shell and runpnpm exec convex deploy --yes --typecheck=enable --preview-create sandbox-sharedfrom an authorized checkout. The create command replaces an existing preview. - Set the repository variable
VRDEX_SANDBOX_CONVEX_URLto the verified cloud URL andVERCEL_SANDBOX_PROJECT_IDto the dedicated Vercel project. Configure sandbox Clerk and Convex. For the worker and broker, see broadcast output credentials and the sandbox procedure ininfra/terraform/restream-worker/README.md. - Issue a deploy key for this preview scoped to running internal queries,
mutations, and actions. Store it as the sensitive preview variable
CONVEX_ADMIN_TOKENin that Vercel project. OAuth consent, token exchange and validation, and MCP operations use those internal calls. The build strips this variable from its pulled file. The workflow's deployment key stays in the Convex deploy step. - Push the reviewed commit to
codex/sandbox. The workflow checks the deployed preview identity before moving the alias. If Convex was recreated, rebind the sandbox broadcast dispatcher and credentials before enabling its worker.
Before reclaiming a closed PR's sandbox backend, compare its Convex URL with
https://sandbox.vrdex.net/api/deployment. If they match, move the alias with
the next sandbox deployment or retire it from the owning Vercel team with
pnpm dlx vercel@54.4.1 alias remove sandbox.vrdex.net. Confirm the old build
is no longer served there before deleting its backend.
The hosted web-domains Terraform stack owns the Route 53 CNAME. The manual
deployment owns which build the alias serves. Remove the one-time DNS import
after the first successful hosted apply adopts the record.