Skip to content

Commit 01c520a

Browse files
fix(console): disable MSW in Vercel production build so requests reach the real backend
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/85a34515-2dbd-4eb1-b164-9078b986ec66 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 511496c commit 01c520a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- **apps/console Vercel deployment** — The production build for Vercel previously ran `vite build` without setting `VITE_USE_MOCK_SERVER=false`, which caused the MSW service worker to be bundled and started in production. As a result, all `/api/v1/*` requests were intercepted locally and the console never actually connected to its configured backend (e.g. `demo.objectstack.ai`). Users hitting routes such as `/apps/<app>/<object>` would see an *object not found* empty state because the MSW mock dataset does not contain every production app/object. `apps/console/vercel.json` now explicitly sets `VITE_USE_MOCK_SERVER=false` in the Vercel `buildCommand`, and the README documents the required `VITE_SERVER_URL` environment variable.
10+
711
### Added
812

913
- **@object-ui/app-shell** - New package providing minimal application rendering engine for third-party integration

apps/console/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ The console supports two distinct running modes:
5858

5959
Both modes support the same features and use the same codebase. Choose development mode for fast iteration, and plugin mode to verify deployment behavior.
6060

61+
## Vercel Deployment
62+
63+
The console can be deployed as a standalone static SPA (e.g. to Vercel) that connects to a remote ObjectStack backend. The build configured in `vercel.json` disables the MSW mock worker (`VITE_USE_MOCK_SERVER=false`) so that all `/api/v1/*` requests go to the real backend.
64+
65+
**Required environment variable** (set in the Vercel project's *Environment Variables* panel):
66+
67+
| Variable | Example | Description |
68+
| --- | --- | --- |
69+
| `VITE_SERVER_URL` | `https://demo.objectstack.ai` | Absolute URL of the ObjectStack backend. When unset, requests default to the same origin — which will 404 on a static SPA host. |
70+
71+
Additional backend requirements for cross-origin deployments:
72+
73+
1. The backend must allow CORS from the SPA origin (`Access-Control-Allow-Origin: <spa-origin>`, `Access-Control-Allow-Credentials: true`).
74+
2. Auth cookies must use `SameSite=None; Secure` so they are sent on cross-site requests.
75+
3. The apps and objects referenced in URLs (e.g. `crm_enterprise`, `lead`) must actually exist in the backend metadata — otherwise the console will render its *object not found* empty state.
76+
6177
## ObjectStack Spec Compliance
6278

6379
### AppSchema Support

apps/console/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
33
"installCommand": "cd ../.. && pnpm install --frozen-lockfile",
4-
"buildCommand": "pnpm msw:init && NODE_OPTIONS=--max-old-space-size=4096 VITE_BASE_PATH=/ vite build",
4+
"buildCommand": "pnpm msw:init && NODE_OPTIONS=--max-old-space-size=4096 VITE_USE_MOCK_SERVER=false VITE_BASE_PATH=/ vite build",
55
"outputDirectory": "dist",
66
"framework": "vite",
77
"rewrites": [

0 commit comments

Comments
 (0)