mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
Per the @vercel/config docs, vercel.ts must expose a named `config` export for Vercel's build pipeline to pick it up. The default export was compiling to a shape Vercel rejected with a misleading "rewrites[0] missing required property source" error.
33 lines
1.7 KiB
TypeScript
33 lines
1.7 KiB
TypeScript
import type { VercelConfig } from '@vercel/config/v1'
|
|
|
|
// Vite's `base` bakes the prefix into asset URLs but leaves the filesystem
|
|
// layout at `dist/client/...`. On Vercel we strip the prefix for file lookups
|
|
// and fall through to the SPA shell. When NEXT_PUBLIC_BASE_PATH is empty
|
|
// these rules collapse to identity rewrites plus the shell fallback.
|
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
|
|
|
|
export const config: VercelConfig = {
|
|
framework: null,
|
|
outputDirectory: 'dist/client',
|
|
rewrites: [
|
|
// API + server-function passthrough. Both funnel through the single
|
|
// `/api/server` Vercel Function that TanStack Start generates. These
|
|
// must come before the asset rule so that extensioned API paths like
|
|
// `/api/foo.json` still hit the function instead of a filesystem lookup.
|
|
// The destination is un-prefixed because the function is registered at
|
|
// `/api/server` regardless of the app's base path.
|
|
{ source: `${basePath}/api/(.*)`, destination: '/api/server' },
|
|
{ source: `${basePath}/_serverFn/(.*)`, destination: '/api/server' },
|
|
// Asset passthrough. Matches anything ending in `.ext` (e.g.
|
|
// `/foo/assets/bundle.abc.js`) and rewrites to the un-prefixed path so
|
|
// Vercel finds it in `dist/client/`. If the file doesn't exist Vercel
|
|
// 404s — important, otherwise missing JS would fall through to the
|
|
// shell rule below and the browser would get HTML where JS was
|
|
// expected.
|
|
{ source: `${basePath}/(.*\\.\\w+)`, destination: '/$1' },
|
|
// SPA fallback. Every remaining path (including the base path itself)
|
|
// gets served the prerendered shell, which boots the client router.
|
|
{ source: `${basePath}/(.*)`, destination: '/_shell.html' },
|
|
],
|
|
}
|