Files
supabase/apps/studio/middleware.ts
T
Ivan Vasilov b5437c630e feat: Add a banner for clock skew in studio (#32866)
* Add a ClockSkewBanner on top of studio.

* Fix the color of the RestrictionBanner.

* Add an API endpoint which return the current UTC time on the server.

* Fix the glob pattern for docs in turbo.json.

* Force docs to build.

* Revert unneeded changes.

* Add feature flag for clock skew banner.

* Add a comment.
2025-01-21 17:45:06 +01:00

31 lines
779 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/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 }
)
}
}