Files
supabase/apps/studio/middleware.ts
T
Saxon FletcherandJoshen Lim 9a79c474c2 Create edge function (#33726)
* page components

* page component changes

* settings but broken saving

* rvert

* use sheet for provider

* styling

* remove things

* Some refactoring and fixing, added JSDocs to layouts

* Smol refactor

* Fix

* Update JSDocs

* updated scaffolding

* update edge functions layout

* remove params

* Clean up

* Spelling

* Clean up FormFieldWrappers

* One last clean up

* create edge functon

* use component

* flag

* fix merge errors

* fix imports

* fix merge issues

* fix import

* fix flag

* remove unused

* move templates

* re-add flag

* Small refactors

* Smol refactors

* Refactor

* add rename and delete via context

* create function fixes

* moved function name

* Smol update

* Small fix for selected state in edge functions side menu when on /new

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-03-05 15:39:02 +01:00

32 lines
811 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/suggest',
'/ai/sql/generate-v2',
'/ai/sql/generate-v3',
'/ai/edge-function/complete',
'/ai/onboarding/design',
'/ai/sql/complete',
'/ai/sql/title',
'/ai/sql/debug',
'/ai/sql/cron',
'/ai/docs',
'/get-ip-address',
'/get-utc-time',
]
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 }
)
}
}