Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Deprecate old settings endpoint in vercel integrate page (#30260)

Joshen Lim959baa82d6da
diff --git a/apps/studio/pages/vercel/integrate.tsx b/apps/studio/pages/vercel/integrate.tsx
index a15800ecf1c..2ce3198ef65 100644
--- a/apps/studio/pages/vercel/integrate.tsx
+++ b/apps/studio/pages/vercel/integrate.tsx
@@ -17,6 +17,7 @@ import { Loading } from 'components/ui/Loading'
import { useProjectsQuery } from 'data/projects/projects-query'
import { withAuth } from 'hooks/misc/withAuth'
import { get } from 'lib/common/fetch'
+import { get as getV2 } from 'data/fetchers'
import { API_URL } from 'lib/constants'
import {
INTEGRATION_ENVS_ALIAS,
@@ -26,6 +27,7 @@ import {
import type { Dictionary } from 'types'
import { Button, Listbox, Select, Separator } from 'ui'
import { PlusCircle, ChevronRight, X } from 'lucide-react'
+import { getAPIKeys } from 'data/config/project-settings-v2-query'
interface IVercelIntegrationStore {
code: string
@@ -351,9 +353,22 @@ const ProjectLinks = observer(() => {
continue
}
// If not, pull project detail info
- const projectDetails = await get(`${API_URL}/props/project/${item.supabaseProjectRef}/api`)
- if (projectDetails.error) {
- console.error('project info error: ', projectDetails.error)
+ if (item.supabaseProjectRef === undefined) {
+ console.error('Project ref is missing')
+ runInAction(() => {
+ item.result = {
+ status: 'fail',
+ message: 'Error: Failed to retrieve project ref',
+ }
+ })
+ continue
+ }
+ const { data: settings, error } = await getV2('/platform/projects/{ref}/settings', {
+ params: { path: { ref: item.supabaseProjectRef } },
+ })
+
+ if (error) {
+ console.error('project info error: ', error)
runInAction(() => {
item.result = {
status: 'fail',
@@ -364,12 +379,12 @@ const ProjectLinks = observer(() => {
}
// Then create env for vercel project with supabase project
+ const endpoint = `https://${settings.app_config?.endpoint ?? '-'}`
+ const { anonKey, serviceKey } = getAPIKeys(settings)
const vercelEnvs = prepareVercelEvns(defaultVercelEnvs, {
- endpoint: `${projectDetails.autoApiService.protocol ?? 'https'}://${
- projectDetails.autoApiService.endpoint ?? '-'
- }`,
- anon_key: projectDetails.autoApiService.defaultApiKey,
- service_key: projectDetails.autoApiService.serviceApiKey,
+ endpoint,
+ anon_key: anonKey?.api_key ?? '',
+ service_key: serviceKey?.api_key ?? '',
})
await Promise.allSettled(