Skip to content

Commit 691e784

Browse files
fix(console): re-enable MSW in Vercel build so record detail URLs resolve on demo.objectui.org
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/1c5f4098-f5a5-40fc-a9ae-1c55c5c66f6d Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent a6bb1bd commit 691e784

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- **"Record not found" on the Vercel demo (`demo.objectui.org`).** The
13+
Vercel build previously set `VITE_USE_MOCK_SERVER=false` in
14+
`apps/console/vercel.json`, which caused the deployed console to
15+
forward every `/api/v1/*` call to an external ObjectStack backend via
16+
`VITE_SERVER_URL`. The example apps (`crm_enterprise`, `todo`,
17+
`kitchen_sink`) are shipped as MSW seed data, not as data in that
18+
remote backend, so clicking a record navigated to
19+
`/apps/.../record/<composite-id>` and `findOne()` returned null —
20+
`DetailView` then rendered its *Record not found* empty state. The
21+
Vercel build is now aligned with the existing `build:vercel` script
22+
in `apps/console/package.json` and sets `VITE_USE_MOCK_SERVER=true`,
23+
so the deployed demo is fully self-contained: MSW boots the
24+
in-memory ObjectStack kernel with the example apps' seed data,
25+
records persist in `localStorage` across reloads, and record detail
26+
URLs resolve against the same kernel that served the list.
27+
`apps/console/README.md` now documents the self-contained demo mode
28+
and the optional "point at a real backend" override.
29+
1030
### Changed
1131

1232
- **`MetadataProvider` now lazy-loads metadata.** Previously the console

apps/console/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,29 @@ Both modes support the same features and use the same codebase. Choose developme
6060

6161
## Vercel Deployment
6262

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.
63+
The console is deployed to Vercel (e.g. `demo.objectui.org`) as a **self-contained static SPA**the MSW mock worker runs in the browser and serves all `/api/v1/*` requests from an in-memory ObjectStack kernel with persistent localStorage storage. No external backend is required.
6464

65-
**Required environment variable** (set in the Vercel project's *Environment Variables* panel):
65+
The build configured in `vercel.json` enables the MSW mock worker (`VITE_USE_MOCK_SERVER=true`) so that:
66+
67+
- Seed data for the example apps (`crm_enterprise`, `todo`, `kitchen_sink`) is loaded on first visit.
68+
- Records, views, and user-created data persist in `localStorage` across page refreshes.
69+
- Record IDs (including composite driver-assigned IDs such as `crm__account-<timestamp>-<n>`) remain stable per-browser, so record detail URLs keep working after reload.
70+
71+
No environment variables are required for the standalone demo deployment.
72+
73+
### Optional: pointing at a real backend
74+
75+
If you want to deploy the console against a live ObjectStack backend instead of the self-contained demo, override the build command to set `VITE_USE_MOCK_SERVER=false` and set `VITE_SERVER_URL` in the Vercel project settings:
6676

6777
| Variable | Example | Description |
6878
| --- | --- | --- |
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. |
79+
| `VITE_SERVER_URL` | `https://your-backend.example.com` | Absolute URL of the ObjectStack backend. When unset, requests default to the same origin — which will 404 on a static SPA host like Vercel. |
7080

7181
Additional backend requirements for cross-origin deployments:
7282

7383
1. The backend must allow CORS from the SPA origin (`Access-Control-Allow-Origin: <spa-origin>`, `Access-Control-Allow-Credentials: true`).
7484
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.
85+
3. The apps and objects referenced in URLs (e.g. `crm_enterprise`, `lead`) must exist in the backend metadata and expose stable record IDs — otherwise the console will render its *object not found* / *record not found* empty state.
7686

7787
## ObjectStack Spec Compliance
7888

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_USE_MOCK_SERVER=false VITE_BASE_PATH=/ vite build",
4+
"buildCommand": "pnpm msw:init && NODE_OPTIONS=--max-old-space-size=4096 VITE_USE_MOCK_SERVER=true VITE_BASE_PATH=/ vite build",
55
"outputDirectory": "dist",
66
"framework": "vite",
77
"rewrites": [

0 commit comments

Comments
 (0)