fix: Vercel production readiness for React/Vite SPA#61
Conversation
…es, deploy docs, CI upgrades Co-authored-by: Krosebrook <214532761+Krosebrook@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes critical Vercel deployment blockers and adds comprehensive deployment documentation for the Interact platform. The changes align environment variables with actual code usage, enable proper React Router SPA fallback routing, establish Node.js version compatibility, upgrade deprecated CI actions, and provide detailed deployment guidance.
Changes:
- Corrected environment variable names in
vercel.jsonfrom incorrectVITE_BASE44_PROJECT_IDto actualVITE_BASE44_APP_IDandVITE_BASE44_BACKEND_URLused in the codebase - Added critical SPA fallback rewrite
/(.*) → /index.htmlto prevent React Router 404s on hard navigation - Replaced invalid
env.NODE_VERSIONin vercel.json with proper Node 20 signals via.nvmrcandpackage.jsonengines field - Upgraded GitHub Actions artifact actions from EOL v3 to v4
- Added comprehensive Vercel deployment documentation to README and created reusable readiness checklist
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
vercel.json |
Fixed env var names (APP_ID + BACKEND_URL), removed invalid NODE_VERSION, added SPA catch-all rewrite, removed no-op API rewrite |
package.json |
Added Node.js engines constraint (>=20) for Vercel detection |
.nvmrc |
Added Node 20 version pin for local development and CI consistency |
.github/workflows/ci.yml |
Upgraded upload-artifact and download-artifact from v3 to v4 (v3 EOL) |
README.md |
Added Deploy to Vercel section with one-click deploy badge, build settings table, required/optional env vars, and SPA routing explanation |
docs/operations/VERCEL_READINESS_CHECKLIST.md |
Created comprehensive 12-point audit template for Vercel deployments across Krosebrook repos |
There was a problem hiding this comment.
3 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="README.md">
<violation number="1" location="README.md:170">
P3: The new Node.js requirement in the Vercel build settings conflicts with the existing Quick Start prerequisite (`Node.js 18+`), leaving contradictory setup guidance in the same README.</violation>
</file>
<file name="vercel.json">
<violation number="1" location="vercel.json:11">
P1: Documentation files reference obsolete `VITE_BASE44_API_KEY` and `VITE_API_URL` environment variables not used by actual application code</violation>
<violation number="2" location="vercel.json:44">
P1: The new SPA rewrite is too broad and rewrites `/api/*` requests to `index.html`, breaking same-origin API calls (for example `/api/logError`). Exclude API routes from the catch-all rewrite.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| { | ||
| "source": "/api/:path*", | ||
| "destination": "/api/:path*" | ||
| "source": "/(.*)", |
There was a problem hiding this comment.
P1: The new SPA rewrite is too broad and rewrites /api/* requests to index.html, breaking same-origin API calls (for example /api/logError). Exclude API routes from the catch-all rewrite.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At vercel.json, line 44:
<comment>The new SPA rewrite is too broad and rewrites `/api/*` requests to `index.html`, breaking same-origin API calls (for example `/api/logError`). Exclude API routes from the catch-all rewrite.</comment>
<file context>
@@ -44,8 +41,8 @@
{
- "source": "/api/:path*",
- "destination": "/api/:path*"
+ "source": "/(.*)",
+ "destination": "/index.html"
}
</file context>
| "source": "/(.*)", | |
| "source": "/((?!api/).*)", |
| @@ -5,13 +5,10 @@ | |||
| "outputDirectory": "dist", | |||
There was a problem hiding this comment.
P1: Documentation files reference obsolete VITE_BASE44_API_KEY and VITE_API_URL environment variables not used by actual application code
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At vercel.json, line 11:
<comment>Documentation files reference obsolete `VITE_BASE44_API_KEY` and `VITE_API_URL` environment variables not used by actual application code</comment>
<file context>
@@ -5,13 +5,10 @@
- "VITE_API_URL": "@api_url",
- "VITE_BASE44_PROJECT_ID": "@base44_project_id"
+ "VITE_BASE44_APP_ID": "@vite_base44_app_id",
+ "VITE_BASE44_BACKEND_URL": "@vite_base44_backend_url"
}
},
</file context>
| | **Build Command** | `npm run build` | | ||
| | **Output Directory** | `dist` | | ||
| | **Install Command** | `npm ci` | | ||
| | **Node.js Version** | 20.x | |
There was a problem hiding this comment.
P3: The new Node.js requirement in the Vercel build settings conflicts with the existing Quick Start prerequisite (Node.js 18+), leaving contradictory setup guidance in the same README.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 170:
<comment>The new Node.js requirement in the Vercel build settings conflicts with the existing Quick Start prerequisite (`Node.js 18+`), leaving contradictory setup guidance in the same README.</comment>
<file context>
@@ -152,7 +153,49 @@ node scripts/generate-prd.js --file ideas/feature.txt
+| **Build Command** | `npm run build` |
+| **Output Directory** | `dist` |
+| **Install Command** | `npm ci` |
+| **Node.js Version** | 20.x |
+
+### Required Environment Variables
</file context>
Several
vercel.jsonmisconfigurations and missing Node version signals would cause broken deployments and silent runtime failures. This PR fixes the blockers and adds deployment documentation.vercel.jsonfixesVITE_BASE44_PROJECT_ID→VITE_BASE44_APP_ID+VITE_BASE44_BACKEND_URL(matches actual app config; old name would silently be undefined at runtime)/(.*) → /index.htmlrewrite; without it, React Router hard-navigations and page refreshes 404/api/:path* → /api/:path*did nothingenv.NODE_VERSIONinvercel.jsonis not how Vercel reads the Node version; replaced with proper signals belowNode version
.nvmrc→20engines.node: ">=20"topackage.jsonCI
actions/upload-artifactandactions/download-artifact:v3→v4(v3 is EOL)Docs
docs/operations/VERCEL_READINESS_CHECKLIST.md: reusable 12-point audit template for other Krosebrook reposOriginal prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Summary by cubic
Prepares this repo for Vercel by fixing vercel.json (env vars and SPA routing), adding Node 20 config, improving deploy docs, and upgrading CI. Aligns with the Linear task to assess Vercel readiness and remove blockers.
New Features
NODE_VERSION, add catch‑all rewrite to/index.html, usenpm ci..nvmrcandengines.node.Migration
npm ci+package-lock.json) and set env vars in Vercel project.Written for commit 04e7eae. Summary will update on new commits.