Files
supabase/apps/studio/proxy.ts
Ivan Vasilov e4925a944c chore: Bump studio nextjs to v16 (#40792)
* Bump Nextjs to v16.

* Fix studio issues.

* move docs graphiql css import to layout

* update sentry

* add missing docs package and fix imports

* only update studio

* ignore next-env.d.ts

* update bundle analyzer

* middleware to proxy

* update lockfile

* remove --turbopack dev flag as it's the default

* Import only types from the monaco editor.

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2025-12-03 14:33:55 +01:00

39 lines
962 B
TypeScript

import { IS_PLATFORM } from 'lib/constants'
import type { NextRequest } from 'next/server'
export const config = {
matcher: '/api/:function*',
}
// [Joshen] Return 404 for all next.js API endpoints EXCEPT the ones we use in hosted:
const HOSTED_SUPPORTED_API_URLS = [
'/ai/sql/generate-v4',
'/ai/feedback/rate',
'/ai/code/complete',
'/ai/sql/cron-v2',
'/ai/sql/title-v2',
'/ai/onboarding/design',
'/ai/feedback/classify',
'/ai/docs',
'/ai/table-quickstart/generate-schemas',
'/get-ip-address',
'/get-utc-time',
'/get-deployment-commit',
'/check-cname',
'/edge-functions/test',
'/edge-functions/body',
'/generate-attachment-url',
]
export function proxy(request: NextRequest) {
if (
IS_PLATFORM &&
!HOSTED_SUPPORTED_API_URLS.some((url) => request.nextUrl.pathname.endsWith(url))
) {
return Response.json(
{ success: false, message: 'Endpoint not supported on hosted' },
{ status: 404 }
)
}
}