Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions apps/server/scripts/build-vercel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set -euo pipefail
# Steps:
# 1. Build the project with turbo (includes studio)
# 2. Bundle the API serverless function (→ api/_handler.js)
# 3. Copy studio dist files to public/ for UI serving
# 3. Copy studio dist files to public/_studio/ for UI serving at /_studio path
# 4. Install external deps in api/node_modules/ (resolve pnpm symlinks)

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

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

echo "[build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js → api/_handler.js"
echo "[build-vercel] Done. Static files in public/_studio/, serverless function in api/[[...route]].js → api/_handler.js"
11 changes: 8 additions & 3 deletions apps/server/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build": {
"env": {
"VITE_RUNTIME_MODE": "server",
"VITE_SERVER_URL": ""
"VITE_SERVER_URL": "",
"VERCEL": "true"
}
},
"functions": {
Expand All @@ -17,14 +18,18 @@
},
"headers": [
{
"source": "/assets/(.*)",
"source": "/_studio/assets/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
]
}
],
"redirects": [
{ "source": "/", "destination": "/_studio", "permanent": false }
],
Comment on lines +27 to +29
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions separating Studio from “future root-level content”, but this redirect forces / to always go to /_studio, which would block serving anything else at the root later. Consider removing this redirect (or making it conditional/temporary) so / remains available.

Copilot uses AI. Check for mistakes.
"rewrites": [
{ "source": "/api/:path*", "destination": "/api/[[...route]]" },
{ "source": "/((?!api/).*)", "destination": "/index.html" }
{ "source": "/_studio/(.*)", "destination": "/_studio/$1" },
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current rewrite rules don’t provide an SPA fallback for deep Studio routes (e.g. /_studio/settings). /_studio/(.*) -> /_studio/$1 is effectively a no-op and will 404 when the file doesn’t exist. Update rewrites to route all non-asset /_studio/:path* requests to /_studio/index.html (while leaving /_studio/assets/* to serve static files).

Suggested change
{ "source": "/_studio/(.*)", "destination": "/_studio/$1" },
{ "source": "/_studio/assets/:path*", "destination": "/_studio/assets/:path*" },
{ "source": "/_studio/:path*", "destination": "/_studio/index.html" },

Copilot uses AI. Check for mistakes.
{ "source": "/_studio", "destination": "/_studio/index.html" }
]
}
2 changes: 1 addition & 1 deletion apps/studio/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const hmrConfig = process.env.VITE_HMR_PORT

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