diff --git a/apps/studio/compat/next/server.ts b/apps/studio/compat/next/server.ts new file mode 100644 index 00000000000..bbba57dca8f --- /dev/null +++ b/apps/studio/compat/next/server.ts @@ -0,0 +1,13 @@ +// Vite-side compat for `next/server`. Workspace source uses `NextResponse` +// (only `.json()`) in two App Router routes and `NextRequest` as a type-only +// import elsewhere. Extend this file if more surface is needed. + +export const NextResponse = { + json: (data: unknown, init?: ResponseInit) => Response.json(data, init), +} + +// NextRequest extends Request with Next-specific fields (nextUrl, cookies, +// ip, geo). None of our workspace source reads those fields at runtime — +// the only imports are type-only. Aliasing to Request keeps TypeScript +// happy without pulling in Next internals. +export type NextRequest = Request diff --git a/apps/studio/vite.config.ts b/apps/studio/vite.config.ts index b87c03762d9..e8040a7f3c3 100644 --- a/apps/studio/vite.config.ts +++ b/apps/studio/vite.config.ts @@ -23,6 +23,7 @@ const nextShims: Record = { 'next/navigation': path.join(compatRoot, 'navigation.ts'), 'next/router': path.join(compatRoot, 'router.ts'), 'next/script': path.join(compatRoot, 'script.tsx'), + 'next/server': path.join(compatRoot, 'server.ts'), } // Combined compat + migration guard: