mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +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>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import { createFileRoute } from '@tanstack/react-router'
|
|
import { IS_PLATFORM } from 'common'
|
|
|
|
import { InternalServerError } from '@/lib/api/apiHelpers'
|
|
import { getStatusPage } from '@/lib/api/status-page'
|
|
|
|
const CACHE_CONTROL_SUCCESS = 'public, s-maxage=300, stale-while-revalidate=300'
|
|
const CACHE_CONTROL_DEGRADED = 'public, s-maxage=60, stale-while-revalidate=60'
|
|
const CACHE_CONTROL_ERROR = 'no-store'
|
|
|
|
async function OPTIONS() {
|
|
if (!IS_PLATFORM) return new Response(null, { status: 404 })
|
|
return new Response(null, {
|
|
status: 204,
|
|
headers: { Allow: 'GET, HEAD, OPTIONS' },
|
|
})
|
|
}
|
|
|
|
async function HEAD() {
|
|
if (!IS_PLATFORM) return new Response(null, { status: 404 })
|
|
return new Response(null, {
|
|
status: 200,
|
|
headers: { 'Cache-Control': CACHE_CONTROL_SUCCESS },
|
|
})
|
|
}
|
|
|
|
async function GET() {
|
|
if (!IS_PLATFORM) return new Response(null, { status: 404 })
|
|
|
|
try {
|
|
const { data, isDegraded } = await getStatusPage()
|
|
return Response.json(data, {
|
|
headers: { 'Cache-Control': isDegraded ? CACHE_CONTROL_DEGRADED : CACHE_CONTROL_SUCCESS },
|
|
})
|
|
} catch (error) {
|
|
let errorCode = 500
|
|
const headers = new Headers({ 'Cache-Control': CACHE_CONTROL_ERROR })
|
|
|
|
if (error instanceof InternalServerError) {
|
|
if (typeof error.details?.status === 'number') errorCode = error.details.status
|
|
if (errorCode === 420) errorCode = 429
|
|
if (errorCode === 429 && typeof error.details?.retryAfter === 'string') {
|
|
headers.set('Retry-After', error.details.retryAfter)
|
|
}
|
|
console.error(
|
|
'Failed to fetch incident.io status page: %s',
|
|
JSON.stringify(
|
|
{
|
|
message: error.message,
|
|
details: error.details,
|
|
},
|
|
null,
|
|
2
|
|
)
|
|
)
|
|
} else {
|
|
console.error('Unexpected error fetching incident.io status page:', error)
|
|
}
|
|
|
|
return Response.json(
|
|
{ error: { message: 'Internal server error' } },
|
|
{ status: errorCode, headers }
|
|
)
|
|
}
|
|
}
|
|
|
|
export const Route = createFileRoute('/api/status-page')({
|
|
server: {
|
|
handlers: {
|
|
GET: () => GET(),
|
|
HEAD: () => HEAD(),
|
|
OPTIONS: () => OPTIONS(),
|
|
},
|
|
},
|
|
})
|