mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
Removes the Next-only entry files and config now that every page lives in `routes/**` (FE-3106). `routes/__root.tsx` already mirrors `pages/_app.tsx` (dayjs plugins, providers, telemetry, error boundary, favicons). Part 13 of the stack. **Depends on:** #53221 **Changed:** - `components/interfaces/App/{NotFoundPage,ServerErrorPage}.tsx` – the 404/500 pages, rendered by `__root.tsx`, now with native `Link`/`useNavigate` and `<img>` - `routes/api/{status-page,scoped-access-token-permissions}.ts` – App Router handlers from `app/api/**` moved in (`NextResponse.json` → `Response.json`); `buildAPIPermissionScopeMap` moves to `lib/api/` - `package.json`, `tsconfig.json` – no `next typegen` step or `.next/types` include - `packages/ui-patterns/.../InstructionBlocks.tsx` – asset map typed `StaticImageData | string`: under Vite a png import is a URL string, which Next's global image types used to hide - `vite.config.ts`, `knip.jsonc`, `turbo.jsonc` and comments across studio – Next build references removed **Removed:** - `pages/{_app,_document,404,500}.tsx`, `pages/_error.jsx`, `pages/README.md`, `app/**`, `next.config.ts`, `proxy.ts`, `instrumentation{,-client}.ts`, `sentry.{server,edge}.config.ts`, `fonts/index.ts` (next/font), `BootTimeoutFallback`, `postcss.config.cjs`, the `next/server` shim - `@next/bundle-analyzer`, `raw-loader`, `postcss`, `@tailwindcss/postcss` dev dependencies Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - Open an unknown URL – the 404 page renders with working "Head back" - `/api/status-page` and `/api/scoped-access-token-permissions` on platform – same JSON and `Cache-Control` - Fonts (Inter, Manrope, Source Code Pro) still load --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { getCSP } from './csp'
|
|
|
|
// Security response headers, applied through `vercel.ts` (Vercel) and Nitro
|
|
// `routeRules` in `vite.config.ts` (self-hosted).
|
|
//
|
|
// Env-gated:
|
|
// - CSP: full `getCSP()` on platform, else just `frame-ancestors 'none'`.
|
|
// - HSTS: only on platform + Vercel (never for self-hosted / previews on a
|
|
// bare IP), so it's omitted rather than sent empty.
|
|
export function getSecurityHeaders(): Array<{ key: string; value: string }> {
|
|
const isPlatform = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
|
|
const isVercel = process.env.VERCEL === '1'
|
|
|
|
const headers = [
|
|
{ key: 'X-Frame-Options', value: 'DENY' },
|
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
|
{
|
|
key: 'Content-Security-Policy',
|
|
value: isPlatform ? getCSP() : "frame-ancestors 'none';",
|
|
},
|
|
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
|
|
]
|
|
|
|
if (isPlatform && isVercel) {
|
|
headers.push({
|
|
key: 'Strict-Transport-Security',
|
|
value: 'max-age=31536000; includeSubDomains; preload',
|
|
})
|
|
}
|
|
|
|
return headers
|
|
}
|