mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-07 16:19:09 +00:00
Compare commits
2 commits
a30ce2ab40
...
c75e76c05e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c75e76c05e | ||
|
|
076e20d7e6 |
2 changed files with 34 additions and 13 deletions
|
|
@ -1,15 +1,5 @@
|
|||
{
|
||||
"$schema": "https://openapi.vercel.sh/vercel.json",
|
||||
"framework": null,
|
||||
"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"
|
||||
}
|
||||
]
|
||||
"buildCommand": "bun run build"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,13 +74,44 @@ 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(),
|
||||
nitro({ routeRules: backendProxyRouteRules() }),
|
||||
viteTsConfigPaths({
|
||||
projects: ["./tsconfig.json"],
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue