Skip to content

Commit e6fa32b

Browse files
Claudehotlong
andauthored
feat: deploy studio to /_studio path in Vercel
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/c3e7d4a1-2f6f-49da-9c2b-064f55111697 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 98abb94 commit e6fa32b

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

apps/server/scripts/build-vercel.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -euo pipefail
1313
# Steps:
1414
# 1. Build the project with turbo (includes studio)
1515
# 2. Bundle the API serverless function (→ api/_handler.js)
16-
# 3. Copy studio dist files to public/ for UI serving
16+
# 3. Copy studio dist files to public/_studio/ for UI serving at /_studio path
1717
# 4. Install external deps in api/node_modules/ (resolve pnpm symlinks)
1818

1919
echo "[build-vercel] Starting server build..."
@@ -27,13 +27,13 @@ cd apps/server
2727
# 2. Bundle API serverless function
2828
node scripts/bundle-api.mjs
2929

30-
# 3. Copy studio dist files to public/ for UI serving
31-
echo "[build-vercel] Copying studio dist to public/..."
30+
# 3. Copy studio dist files to public/_studio/ for UI serving at /_studio path
31+
echo "[build-vercel] Copying studio dist to public/_studio/..."
3232
rm -rf public
33-
mkdir -p public
33+
mkdir -p public/_studio
3434
if [ -d "../studio/dist" ]; then
35-
cp -r ../studio/dist/* public/
36-
echo "[build-vercel] ✓ Copied studio dist to public/"
35+
cp -r ../studio/dist/* public/_studio/
36+
echo "[build-vercel] ✓ Copied studio dist to public/_studio/"
3737
else
3838
echo "[build-vercel] ⚠ Studio dist not found (skipped)"
3939
fi
@@ -60,4 +60,4 @@ rm package.json
6060
cd ..
6161
echo "[build-vercel] ✓ External dependencies installed in api/node_modules/"
6262

63-
echo "[build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js → api/_handler.js"
63+
echo "[build-vercel] Done. Static files in public/_studio/, serverless function in api/[[...route]].js → api/_handler.js"

apps/server/vercel.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"build": {
77
"env": {
88
"VITE_RUNTIME_MODE": "server",
9-
"VITE_SERVER_URL": ""
9+
"VITE_SERVER_URL": "",
10+
"VERCEL": "true"
1011
}
1112
},
1213
"functions": {
@@ -17,14 +18,15 @@
1718
},
1819
"headers": [
1920
{
20-
"source": "/assets/(.*)",
21+
"source": "/_studio/assets/(.*)",
2122
"headers": [
2223
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
2324
]
2425
}
2526
],
2627
"rewrites": [
2728
{ "source": "/api/:path*", "destination": "/api/[[...route]]" },
28-
{ "source": "/((?!api/).*)", "destination": "/index.html" }
29+
{ "source": "/_studio/(.*)", "destination": "/_studio/$1" },
30+
{ "source": "/_studio", "destination": "/_studio/index.html" }
2931
]
3032
}

apps/studio/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const hmrConfig = process.env.VITE_HMR_PORT
99

1010
// https://vitejs.dev/config/
1111
export default defineConfig({
12-
base: process.env.VITE_BASE || './', // Relative base for sub-path mounting (e.g. /_studio/)
12+
base: process.env.VITE_BASE || (process.env.VERCEL ? '/_studio/' : './'), // Use /_studio/ for Vercel, relative base for other sub-path mounting
1313
resolve: {
1414
dedupe: ['react', 'react-dom'],
1515
alias: {

0 commit comments

Comments
 (0)