Skip to content

Commit 5525dd9

Browse files
Merge pull request #1134 from objectstack-ai/claude/configure-studio-server-mode
Fix Studio server mode for app-host Vercel deployment
2 parents f2934f1 + 102e5b5 commit 5525dd9

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

examples/app-host/DEPLOYMENT.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,18 @@ The build is configured in `vercel.json`:
5656

5757
- **Install Command**: `cd ../.. && pnpm install` (installs monorepo dependencies)
5858
- **Build Command**: `bash scripts/build-vercel.sh` (builds and bundles the application)
59-
- **Framework**: `hono` (uses Vercel's Hono framework preset)
59+
- **Framework**: `null` (disabled - uses custom serverless function)
60+
- **Build Environment Variables**:
61+
- `VITE_RUNTIME_MODE=server`: Configures Studio to run in server mode (connects to API instead of using MSW)
62+
- `VITE_SERVER_URL=""`: Empty string for same-origin API requests (Studio and API served from same domain)
6063

6164
## How It Works
6265

6366
1. **Build Process** (`scripts/build-vercel.sh`):
64-
- Builds the TypeScript project using Turbo
67+
- Builds both app-host and Studio using Turbo
68+
- Studio is built with `VITE_RUNTIME_MODE=server` (set in vercel.json build.env)
6569
- Bundles the server code using esbuild (`scripts/bundle-api.mjs`)
70+
- Copies Studio dist files to `public/` for static file serving
6671

6772
2. **API Handler** (`api/[[...route]].js`):
6873
- Committed catch-all route handler that Vercel detects pre-build
@@ -79,6 +84,12 @@ The build is configured in `vercel.json`:
7984
- Provides REST API at `/api/v1` prefix
8085
- Includes authentication via AuthPlugin
8186

87+
5. **Studio UI** (Frontend SPA):
88+
- Built with Vite in server mode (not MSW mode)
89+
- Served as static files from `public/` directory
90+
- Connects to same-origin API server (relative URLs)
91+
- All API requests go to `/api/v1/*` endpoints
92+
8293
## Architecture
8394

8495
The deployment follows Vercel's serverless function pattern:
@@ -112,13 +123,14 @@ pnpm dev
112123
curl http://localhost:3000/api/v1/discovery
113124
```
114125

115-
## Accessing the API
126+
## Accessing the Application
116127

117-
After deployment, your API will be available at:
128+
After deployment, your application will be available at:
118129

119-
- Discovery: `https://your-app.vercel.app/api/v1/discovery`
120-
- Data API: `https://your-app.vercel.app/api/v1/data/:object`
121-
- Meta API: `https://your-app.vercel.app/api/v1/meta/:type`
130+
- **Studio UI**: `https://your-app.vercel.app/` (main interface)
131+
- **API Discovery**: `https://your-app.vercel.app/api/v1/discovery`
132+
- **Data API**: `https://your-app.vercel.app/api/v1/data/:object`
133+
- **Meta API**: `https://your-app.vercel.app/api/v1/meta/:type`
122134

123135
## Troubleshooting
124136

@@ -141,6 +153,15 @@ After deployment, your API will be available at:
141153
- Check that your Turso database is accessible (not paused)
142154
- The deployment uses TursoDriver in **remote mode** (HTTP-only), which doesn't require native modules like better-sqlite3
143155

156+
### Studio Still in MSW Mode
157+
158+
If Studio is running in MSW (Mock Service Worker) mode instead of server mode:
159+
160+
- Verify that `vercel.json` includes the `build.env` section with `VITE_RUNTIME_MODE=server`
161+
- Check that the build process logs show "VITE_RUNTIME_MODE=server" during Studio build
162+
- Open browser DevTools Console and check for `[Console Config]` log to verify runtime mode
163+
- Clear Vercel build cache and redeploy: `vercel --force`
164+
144165
## References
145166

146167
- [Vercel Hono Documentation](https://vercel.com/docs/frameworks/backend/hono)

examples/app-host/vercel.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"framework": null,
44
"installCommand": "cd ../.. && pnpm install",
55
"buildCommand": "bash scripts/build-vercel.sh",
6+
"build": {
7+
"env": {
8+
"VITE_RUNTIME_MODE": "server",
9+
"VITE_SERVER_URL": ""
10+
}
11+
},
612
"functions": {
713
"api/**/*.js": {
814
"memory": 1024,

0 commit comments

Comments
 (0)