Fix Vercel deployment config and add DEPLOYMENT.md#235
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add build:vercel script that combines apps/web/dist + apps/site/out - Update vercel.json: use build:vercel, add cleanUrls, fix SPA fallback to exclude /docs/ - Create DEPLOYMENT.md documenting pnpm start, Vercel, and dist folders - Update README.md with deployment section and link to guide Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adjusts the Vercel deployment configuration so the Vite SPA and exported docs site can be served correctly from a single static output directory, and documents the supported deployment modes for ObjectOS.
Changes:
- Update
vercel.jsonto use a Vercel-specific build command, enablecleanUrls, and refine SPA fallback rewrites to avoid/docs/*. - Add
build:vercelto combineapps/site/outintoapps/web/dist/docsfor a single VerceloutputDirectory. - Add
DEPLOYMENT.mdand updateREADME.mdwith Vercel deployment guidance.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vercel.json | Switches to build:vercel, enables cleanUrls, adjusts SPA fallback rewrite to exclude docs paths. |
| package.json | Adds build:vercel script to build via Turbo and copy docs output into the SPA dist folder. |
| README.md | Updates production build instructions and links to the new deployment guide + Vercel section. |
| DEPLOYMENT.md | New deployment documentation covering self-hosted vs Vercel architecture, outputs, routing, and limitations. |
| "rewrites": [ | ||
| { "source": "/api/v1/(.*)", "destination": "/api" }, | ||
| { "source": "/((?!api/).*)", "destination": "/index.html" } | ||
| { "source": "/((?!api/|docs/).*)", "destination": "/index.html" } |
There was a problem hiding this comment.
The SPA fallback rewrite excludes /docs/… but not the /docs root path (no trailing slash). A request to /docs will match this regex and be rewritten to /index.html, breaking the docs landing page unless the client always includes the trailing slash. Consider updating the negative lookahead to exclude docs with or without a trailing slash (e.g., docs(?:/|$)), or add an explicit rewrite/redirect for /docs → /docs/.
| { "source": "/((?!api/|docs/).*)", "destination": "/index.html" } | |
| { "source": "/((?!api/|docs(?:/|$)).*)", "destination": "/index.html" } |
| "dev:all": "concurrently -n api,web,site -c blue,green,yellow \"pnpm objectstack:serve\" \"pnpm web:dev\" \"pnpm site:dev\"", | ||
| "start": "pnpm objectstack:serve", | ||
| "build": "turbo run build", | ||
| "build:vercel": "turbo run build && cp -r apps/site/out apps/web/dist/docs", |
There was a problem hiding this comment.
build:vercel copies apps/site/out into apps/web/dist/docs without clearing the destination first. If apps/web/dist/docs already exists (e.g., repeated local builds), cp -r will nest the output (ending up with docs/out/...) or leave stale files. Consider removing apps/web/dist/docs before copying, and/or copying the contents of out/ into docs/ to make the script idempotent.
| "build:vercel": "turbo run build && cp -r apps/site/out apps/web/dist/docs", | |
| "build:vercel": "turbo run build && rm -rf apps/web/dist/docs && mkdir -p apps/web/dist/docs && cp -r apps/site/out/. apps/web/dist/docs", |
Vercel deployment was misconfigured: docs site (
apps/site/out) was not included in the output, and the SPA fallback rewrite swallowed/docs/*paths.Changes
vercel.json: SwitchbuildCommandtobuild:vercel, addcleanUrls, fix SPA fallback regex from/((?!api/).*)→/((?!api/|docs/).*)so/docs/*serves static files from CDNpackage.json: Addbuild:vercelscript — runsturbo run buildthen copiesapps/site/out→apps/web/dist/docs/to produce a single combined output directoryDEPLOYMENT.md: Documents both deployment modes (self-hostedpnpm startvs Vercel serverless), build outputs, URL routing, env vars, and Vercel limitations (no WebSocket, cold-start, function timeout)README.md: Add "Deploy to Vercel" section, link to deployment guidedist folder layout
Routing
pnpm start)/api/v1/*api/index.tsserverless fn/console/*apps/web/dist/)/docs/*apps/site/outapps/web/dist/docs//*index.html💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.