Files
supabase/apps/studio/middleware.ts
T
Joshen LimandSaxon Fletcher 256dbb7f38 Feature flag MCP changes (#36689)
* Feature flag assistant endpoint + opt in UI

* Feature flag bedrock stuff for the other endpoints like title, cron, complete

* add edge function complete v2

* revert to old complete

* Revert hardcode

* fix chart colour

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
2025-06-26 18:41:31 +08:00

39 lines
1.0 KiB
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 = [
// These are using OpenAI, can be removed once Bedrock is default
'/ai/sql/generate-v3',
'/ai/sql/complete',
'/ai/sql/cron',
'/ai/sql/title',
// These are using Bedrock
'/ai/sql/generate-v4',
'/ai/sql/complete-v2',
'/ai/sql/cron-v2',
'/ai/sql/title-v2',
'/ai/edge-function/complete-v2',
// Others
'/ai/edge-function/complete',
'/ai/onboarding/design',
'/ai/feedback/classify',
'/get-ip-address',
'/get-utc-time',
'/edge-functions/test',
'/edge-functions/body',
]
export function middleware(request: NextRequest) {
if (IS_PLATFORM && !HOSTED_SUPPORTED_API_URLS.some((url) => request.url.endsWith(url))) {
return Response.json(
{ success: false, message: 'Endpoint not supported on hosted' },
{ status: 404 }
)
}
}