Compare commits

..

No commits in common. "c75e76c05e791145f14e42f6f36d0109598442ef" and "a30ce2ab4055c87699e1cea15f156c3b31448acc" have entirely different histories.

2 changed files with 13 additions and 34 deletions

View file

@ -1,5 +1,15 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"framework": null,
"buildCommand": "bun run build"
"buildCommand": "bun run build",
"outputDirectory": ".output/public",
"rewrites": [
{
"source": "/dashboard/api/:path*",
"destination": "https://open-swe-v3-f2834ffc0df05a46a10262a9690e8490.us.langgraph.app/dashboard/api/:path*"
},
{
"source": "/(.*)",
"destination": "/_shell.html"
}
]
}

View file

@ -74,44 +74,13 @@ function mockHarnessProxy(): Plugin | null {
}
}
// Same-origin proxy for the dashboard API. Vercel reads vercel.json BEFORE the build
// and never interpolates env into it, and prod promotes by fast-forward (so `dev` and
// `main` ship a byte-identical vercel.json that cannot encode a per-project backend).
// So the per-project backend is driven through Nitro instead: this `routeRules` proxy
// is compiled by Nitro's Vercel preset into a CDN-level rewrite in
// `.vercel/output/config.json` at build time, reading LANGGRAPH_BACKEND_URL from the
// per-project Vercel env var. Proxy (not redirect) keeps the osw_session cookie
// first-party on the Vercel origin. The `**` wildcard maps 1:1 to the destination.
function backendProxyRouteRules():
| Record<string, { proxy: string }>
| undefined {
const backend = process.env.LANGGRAPH_BACKEND_URL?.replace(/\/$/, "")
// Nitro's Vercel preset auto-activates from the VERCEL env var; NITRO_PRESET=vercel
// forces it locally. On Vercel the backend is mandatory — fail loudly rather than
// ship a build whose API calls 404, which is exactly how the previous approach broke.
const onVercel =
!!process.env.VERCEL || process.env.NITRO_PRESET === "vercel"
if (!backend) {
if (onVercel) {
throw new Error(
"LANGGRAPH_BACKEND_URL is required for Vercel builds (set it per Vercel " +
"project: dev project -> dev langgraph URL, prod project -> prod langgraph URL).",
)
}
// Off Vercel with no backend configured (plain local `vite build`, tests): omit the
// proxy. Local dev gets its API via the E2E_HARNESS mock proxy above instead.
return undefined
}
return { "/dashboard/api/**": { proxy: `${backend}/dashboard/api/**` } }
}
const config = defineConfig({
optimizeDeps: { include: ["workbox-window"] },
worker: { format: "es" },
plugins: [
mockHarnessProxy(),
devtools(),
nitro({ routeRules: backendProxyRouteRules() }),
nitro(),
viteTsConfigPaths({
projects: ["./tsconfig.json"],
}),