The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: "possible fix" - always use project ref incase the project rest url changes
Jonathan Summers-Muir1d1b4a5d9c3e
diff --git a/studio/components/layouts/ProjectLayout/ConnectingState.tsx b/studio/components/layouts/ProjectLayout/ConnectingState.tsxindex db284a04e88..102cbae075f 100644--- a/studio/components/layouts/ProjectLayout/ConnectingState.tsx+++ b/studio/components/layouts/ProjectLayout/ConnectingState.tsx@@ -37,7 +37,8 @@ const ConnectingState: FC<Props> = ({ project }) => {}, [project])const testProjectConnection = async () => {- const result = await pingPostgrest(project.restUrl!, {+ console.log('project.restUrl', project.restUrl)+ const result = await pingPostgrest(project.restUrl!, project.ref, {kpsVersion: project.kpsVersion,})if (result) {diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsxindex 15b9292cd35..00389e1cb00 100644--- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx+++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx@@ -114,6 +114,8 @@ const ContentWrapper: FC<ContentWrapperProps> = observer(({ isLoading, childrenconst isProjectPausing = ui.selectedProject?.status === PROJECT_STATUS.GOING_DOWNconst isProjectOffline = ui.selectedProject?.postgrestStatus === 'OFFLINE'+ console.log('ui.selectedProject', ui.selectedProject)+return (<>{isLoading || ui.selectedProject === undefined ? (diff --git a/studio/lib/pingPostgrest.ts b/studio/lib/pingPostgrest.tsindex 169b9afd327..21d71be3039 100644--- a/studio/lib/pingPostgrest.ts+++ b/studio/lib/pingPostgrest.ts@@ -1,3 +1,4 @@+import { String } from 'lodash'import semver from 'semver'import { headWithTimeout, getWithTimeout } from './common/fetch'import { API_URL } from './constants'@@ -16,12 +17,13 @@ import { API_URL } from './constants'*/async function pingPostgrest(restUrl: string,+ projectRef: string,options?: {kpsVersion?: stringtimeout?: number}) {- const projectRef = restUrl.match(/https:\/\/(\w+)\.supabase\./)?.[1]+ console.log('projectRef inside ping postgres', projectRef)if (projectRef === undefined) return falseconst serviceApiKey = await getServiceApiKey(projectRef, options?.timeout)if (serviceApiKey === undefined) return false@@ -41,7 +43,10 @@ async function pingPostgrest(}export default pingPostgrest-const getServiceApiKey = async (projectRef: string, timeout = DEFAULT_TIMEOUT_MILLISECONDS): Promise<string | undefined> => {+const getServiceApiKey = async (+ projectRef: string,+ timeout = DEFAULT_TIMEOUT_MILLISECONDS+): Promise<string | undefined> => {const response = await getWithTimeout(`${API_URL}/props/project/${projectRef}/api`, { timeout })if (response.error || response.autoApiService.service_api_keys.length === 0) return undefinedreturn response.autoApiService.serviceApiKeydiff --git a/studio/stores/app/ProjectStore.ts b/studio/stores/app/ProjectStore.tsindex 87744a165a8..028f9bc31f6 100644--- a/studio/stores/app/ProjectStore.ts+++ b/studio/stores/app/ProjectStore.ts@@ -62,11 +62,8 @@ export default class ProjectStore extends PostgresMetaInterface<Project> {}async pingPostgrest(project: Project): Promise<'ONLINE' | 'OFFLINE' | undefined> {- if (- project.status === PROJECT_STATUS.ACTIVE_HEALTHY &&- project.restUrl- ) {- const success = await pingPostgrest(project.restUrl, {+ if (project.status === PROJECT_STATUS.ACTIVE_HEALTHY && project.restUrl) {+ const success = await pingPostgrest(project.restUrl, project.ref, {kpsVersion: project.kpsVersion,})return success ? 'ONLINE' : 'OFFLINE'