Vercel preview deployment
This is the first hosted deployment path for apps/web. It is intentionally narrow: get a live Vercel URL for every pull request and keep unsafe public states locked. Production hardening belongs here only after an explicit follow-up issue owns it.
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 PR 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 are missing, the Vercel Preview job passes and writes a step summary explaining that deployment is skipped. This keeps baseline CI green before the hosted project is linked, while making the missing live-deploy blocker explicit.
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 runs convex deploy --preview-create pr-<number> before the Vercel build and writes the resulting NEXT_PUBLIC_CONVEX_URL into the Vercel build environment. This keeps PR previews from accidentally pointing at stale shared dev/prod Convex functions.
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.VRDEX_REQUIRE_CONVEX_URL=true: optional; use when previews must fail instead of showing missing-backend states.NEXT_PUBLIC_VRDEX_SUBMISSIONS_AUTH_READY=false: legacy flag; auth-backed submissions now rely on Convex Auth configuration.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.
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 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_VRDEX_SUBMISSIONS_AUTH_READY=falseVRDEX_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
Current ownership: these staging E2E environment variables are bootstrap-managed manual Vercel settings, not Terraform-owned. The infra/terraform/vercel stack currently owns only hosted PostHog client environment variables (NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST) for production, default preview, and configured staging custom environment IDs. Until E2E helper variables are explicitly added to or imported into Terraform, update this document and the Vercel secret store together, 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 - secret
VRDEX_HOSTED_E2E_BROWSER_TOKEN
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
If any required setting is missing, the workflow writes a skip summary and exits successfully instead of partially deploying staging. When enabled, the workflow deploys Convex development functions first, then deploys Vercel staging, then runs pnpm test:e2e:hosted against VRDEX_HOSTED_E2E_BASE_URL.
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.
- public submissions are marked auth-ready before auth exists.
NEXT_PUBLIC_CONVEX_URLis invalid.NEXT_PUBLIC_CONVEX_URLpoints at localhost during a Vercel build.VRDEX_REQUIRE_CONVEX_URL=trueandNEXT_PUBLIC_CONVEX_URLis missing.
Live smoke check
After a preview deployment, visit:
/for the public shell/deploymentfor Vercel environment and commit metadata/server-statusfor the server-side Convex read baseline/submitto confirm signed-out users are routed to sign in before writing
The PR workflow posts a Vercel Preview Deployment comment with both the preview URL and /deployment URL once Vercel secrets are configured.