mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
* 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>
39 lines
1.0 KiB
TypeScript
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 }
|
|
)
|
|
}
|
|
}
|