Skip to content

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

fix: Use protocol property when building API url (#30332)

Ivan Vasilovf29003e0e715
diff --git a/apps/studio/components/interfaces/App/CommandMenu/ApiUrl.tsx b/apps/studio/components/interfaces/App/CommandMenu/ApiUrl.tsx
index 1205a8f3333..50a6fb33c3b 100644
--- a/apps/studio/components/interfaces/App/CommandMenu/ApiUrl.tsx
+++ b/apps/studio/components/interfaces/App/CommandMenu/ApiUrl.tsx
@@ -17,9 +17,9 @@ export function useApiUrlCommand() {
{ enabled: !!project }
)
- const apiUrl = settings?.app_config?.endpoint
- ? `https://${settings.app_config.endpoint}`
- : undefined
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
+ const apiUrl = endpoint ? `${protocol}://${endpoint}` : undefined
useRegisterCommands(
COMMAND_MENU_SECTIONS.ACTIONS,
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index 38e3a3632c0..1718070d3a5 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@ -111,7 +111,9 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
}
const { data: settings } = useProjectSettingsV2Query({ projectRef })
- const apiUrl = `https://${settings?.app_config?.endpoint}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
+ const apiUrl = `${protocol}://${endpoint}`
const { data: customDomainData } = useCustomDomainsQuery({ projectRef })
diff --git a/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx
index aa19b6e4c80..04a923d0082 100644
--- a/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx
@@ -69,7 +69,8 @@ export const BanUserModal = ({ visible, user, onClose }: BanUserModalProps) => {
}
const durationHours = data.unit === 'hours' ? Number(data.value) : Number(data.value) * 24
- const endpoint = settings.app_config?.endpoint
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
const { serviceKey } = getAPIKeys(settings)
if (!endpoint) return toast.error(`Failed to ban user: Unable to retrieve API endpoint`)
@@ -77,7 +78,7 @@ export const BanUserModal = ({ visible, user, onClose }: BanUserModalProps) => {
updateUser({
projectRef,
- protocol: 'https',
+ protocol,
endpoint,
serviceApiKey: serviceKey.api_key,
userId: user.id,
diff --git a/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx
index 41a421ddcd6..8e0b2467781 100644
--- a/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx
@@ -60,6 +60,7 @@ const CreateUserModal = ({ visible, setVisible }: CreateUserModalProps) => {
if (!isSuccess) {
return toast.error(`Failed to create user: Error loading project config`)
}
+ const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint
const { serviceKey } = getAPIKeys(settings)
@@ -69,8 +70,8 @@ const CreateUserModal = ({ visible, setVisible }: CreateUserModalProps) => {
createUser({
projectRef,
+ protocol,
endpoint,
- protocol: 'https',
serviceApiKey: serviceKey.api_key,
user: values,
})
diff --git a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
index e477d825e43..55da43b43fe 100644
--- a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
@@ -149,7 +149,8 @@ export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => {
return toast.error(`Failed to ban user: User ID not found`)
}
- const endpoint = settings.app_config?.endpoint
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
const { serviceKey } = getAPIKeys(settings)
if (!endpoint) return toast.error(`Failed to unban user: Unable to retrieve API endpoint`)
@@ -157,7 +158,7 @@ export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => {
updateUser({
projectRef,
- protocol: 'https',
+ protocol,
endpoint,
serviceApiKey: serviceKey.api_key,
userId: user.id,
diff --git a/apps/studio/components/interfaces/Docs/Authentication.tsx b/apps/studio/components/interfaces/Docs/Authentication.tsx
index 6fe9c58a950..418e8f8025e 100644
--- a/apps/studio/components/interfaces/Docs/Authentication.tsx
+++ b/apps/studio/components/interfaces/Docs/Authentication.tsx
@@ -15,7 +15,9 @@ const Authentication = ({ selectedLang, showApiKey }: AuthenticationProps) => {
const { data: settings } = useProjectSettingsV2Query({ projectRef })
const { anonKey, serviceKey } = getAPIKeys(settings)
- const endpoint = `https://${settings?.app_config?.endpoint ?? ''}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint
+ const endpoint = `${protocol}://${hostEndpoint ?? ''}`
// [Joshen] ShowApiKey should really be a boolean, its confusing
const defaultApiKey =
diff --git a/apps/studio/components/interfaces/Docs/Introduction.tsx b/apps/studio/components/interfaces/Docs/Introduction.tsx
index c187493a1f0..e102f008de5 100644
--- a/apps/studio/components/interfaces/Docs/Introduction.tsx
+++ b/apps/studio/components/interfaces/Docs/Introduction.tsx
@@ -16,7 +16,9 @@ export default function Introduction({ selectedLang }: Props) {
const { data: settings } = useProjectSettingsV2Query({ projectRef })
const { data: config } = useProjectPostgrestConfigQuery({ projectRef })
- const endpoint = `https://${settings?.app_config?.endpoint ?? ''}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint
+ const endpoint = `${protocol}://${hostEndpoint ?? ''}`
const isPublicSchemaEnabled = config?.db_schema
.split(',')
diff --git a/apps/studio/components/interfaces/Docs/Pages/UserManagement.tsx b/apps/studio/components/interfaces/Docs/Pages/UserManagement.tsx
index b32c5168a46..036acd17192 100644
--- a/apps/studio/components/interfaces/Docs/Pages/UserManagement.tsx
+++ b/apps/studio/components/interfaces/Docs/Pages/UserManagement.tsx
@@ -20,7 +20,9 @@ export default function UserManagement({ selectedLang, showApiKey }: UserManagem
const keyToShow = showApiKey ? showApiKey : 'SUPABASE_KEY'
const { data: settings } = useProjectSettingsV2Query({ projectRef })
- const endpoint = `https://${settings?.app_config?.endpoint ?? ''}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint ?? ''
+ const endpoint = `${protocol}://${hostEndpoint ?? ''}`
return (
<>
diff --git a/apps/studio/components/interfaces/Docs/RpcContent.tsx b/apps/studio/components/interfaces/Docs/RpcContent.tsx
index b3f0a91d016..764e38814fe 100644
--- a/apps/studio/components/interfaces/Docs/RpcContent.tsx
+++ b/apps/studio/components/interfaces/Docs/RpcContent.tsx
@@ -29,7 +29,9 @@ const RpcContent = ({
}: RpcContentProps) => {
const { ref: projectRef } = useParams()
const { data: settings } = useProjectSettingsV2Query({ projectRef })
- const endpoint = `https://${settings?.app_config?.endpoint ?? ''}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint ?? ''
+ const endpoint = `${protocol}://${hostEndpoint ?? ''}`
const meta = rpcs[rpcId]
const pathKey = `/rpc/${rpcId}`
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
index aca153eb113..963daeab751 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
@@ -56,11 +56,12 @@ const EdgeFunctionDetails = () => {
const { anonKey } = getAPIKeys(settings)
const apiKey = anonKey?.api_key ?? '[YOUR ANON KEY]'
+ const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint ?? ''
const functionUrl =
customDomainData?.customDomain?.status === 'active'
? `https://${customDomainData.customDomain.hostname}/functions/v1/${selectedFunction?.slug}`
- : `https://${endpoint}/functions/v1/${selectedFunction?.slug}`
+ : `${protocol}://${endpoint}/functions/v1/${selectedFunction?.slug}`
const { managementCommands, secretCommands, invokeCommands } = generateCLICommands(
selectedFunction,
diff --git a/apps/studio/components/interfaces/Functions/TerminalInstructions.tsx b/apps/studio/components/interfaces/Functions/TerminalInstructions.tsx
index be42fca37be..6c49a15927b 100644
--- a/apps/studio/components/interfaces/Functions/TerminalInstructions.tsx
+++ b/apps/studio/components/interfaces/Functions/TerminalInstructions.tsx
@@ -35,11 +35,13 @@ const TerminalInstructions = forwardRef<
const { anonKey } = getAPIKeys(settings)
const apiKey = anonKey?.api_key ?? '[YOUR ANON KEY]'
+
+ const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint ?? ''
const functionsEndpoint =
customDomainData?.customDomain?.status === 'active'
? `https://${customDomainData.customDomain.hostname}/functions/v1`
- : `https://${endpoint}/functions/v1`
+ : `${protocol}://${endpoint}/functions/v1`
// get the .co or .net TLD from the restUrl
const restUrl = `https://${endpoint}`
diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.tsx b/apps/studio/components/interfaces/Home/Connect/Connect.tsx
index 71517f29d5f..bcab28afdc2 100644
--- a/apps/studio/components/interfaces/Home/Connect/Connect.tsx
+++ b/apps/studio/components/interfaces/Home/Connect/Connect.tsx
@@ -128,8 +128,9 @@ const Connect = () => {
return []
}
- const endpoint = settings?.app_config?.endpoint
- const apiHost = canReadAPIKeys ? `https://${endpoint ?? '-'}` : ''
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint ?? ''
+ const apiHost = canReadAPIKeys ? `${protocol}://${endpoint ?? '-'}` : ''
const apiUrl = canReadAPIKeys ? apiHost : null
const { anonKey } = canReadAPIKeys ? getAPIKeys(settings) : { anonKey: null }
diff --git a/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx b/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
index 7265f3c38f5..04cae0f6bae 100644
--- a/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
+++ b/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
@@ -58,8 +58,9 @@ const APIKeys = () => {
const isNotUpdatingJwtSecret =
jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated
+ const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint
- const apiUrl = `https://${endpoint ?? '-'}`
+ const apiUrl = `${protocol}://${endpoint ?? '-'}`
const apiKeys = settings?.service_api_keys ?? []
const { anonKey } = getAPIKeys(settings)
diff --git a/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.tsx b/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.tsx
index ee8e926145a..e7e6321e9ae 100644
--- a/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.tsx
+++ b/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.tsx
@@ -49,10 +49,12 @@ const ProjectAPIDocs = () => {
const apikey = showKeys
? anonKey?.api_key ?? 'SUPABASE_CLIENT_ANON_KEY'
: 'SUPABASE_CLIENT_ANON_KEY'
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint
const endpoint =
customDomainData?.customDomain?.status === 'active'
? `https://${customDomainData.customDomain?.hostname}`
- : `https://${settings?.app_config?.endpoint ?? ''}`
+ : `${protocol}://${hostEndpoint ?? ''}`
return (
<SidePanel
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
index 09a861e5a3c..fa395823fd3 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
@@ -22,9 +22,7 @@ export const RealtimeTokensPopover = ({ config, onChangeConfig }: RealtimeTokens
const { anonKey, serviceKey } = getAPIKeys(settings)
const { data: postgrestConfig } = useProjectPostgrestConfigQuery(
- {
- projectRef: config.projectRef,
- },
+ { projectRef: config.projectRef },
{ enabled: IS_PLATFORM }
)
const jwtSecret = postgrestConfig?.jwt_secret
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts b/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
index 2397b6b1d5d..13b6030c517 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
+++ b/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
@@ -78,10 +78,10 @@ export const useRealtimeMessages = (
const { data: settings } = useProjectSettingsV2Query({ projectRef: projectRef })
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
// the default host is prod until the correct one comes through an API call.
- const host = settings
- ? `https://${settings.app_config?.endpoint}`
- : `https://${projectRef}.supabase.co`
+ const host = settings ? `${protocol}://${endpoint}` : `https://${projectRef}.supabase.co`
const realtimeUrl = `${host}/realtime/v1`.replace(/^http/i, 'ws')
diff --git a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
index cacfb57f7e3..b5d8eff7df0 100644
--- a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
+++ b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
@@ -37,7 +37,8 @@ const StorageLayout = ({ title, children }: StorageLayoutProps) => {
if (isPaused) return
if (endpoint) {
- storageExplorerStore.initStore(projectRef!, endpoint, serviceApiKey, 'https')
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ storageExplorerStore.initStore(projectRef!, endpoint, serviceApiKey, protocol)
} else {
toast.error(
'Failed to fetch project configuration. Try refreshing your browser, or reach out to us at [email protected]'
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/useCopyUrl.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/useCopyUrl.tsx
index 7543eb48899..9cdf41fd815 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/useCopyUrl.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/useCopyUrl.tsx
@@ -8,7 +8,9 @@ export const useCopyUrl = (ref: string) => {
const { data: customDomainData } = useCustomDomainsQuery({ projectRef: ref })
const { data: settings } = useProjectSettingsV2Query({ projectRef: ref })
- const apiUrl = `https://${settings?.app_config?.endpoint ?? '-'}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
+ const apiUrl = `${protocol}://${endpoint ?? '-'}`
const onCopyUrl = (name: string, url: string | Promise<string>) => {
const formattedUrl = Promise.resolve(url).then((url) => {
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx
index 1e58b14c992..961bbe29a72 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx
@@ -41,9 +41,10 @@ export const S3Connection = () => {
{ enabled: canReadS3Credentials }
)
+ const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint
const hasStorageCreds = storageCreds?.data && storageCreds.data.length > 0
- const s3connectionUrl = getConnectionURL(projectRef ?? '', endpoint)
+ const s3connectionUrl = getConnectionURL(projectRef ?? '', protocol, endpoint)
return (
<>
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils.ts b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils.ts
index d04aa865ea0..1cea637616b 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils.ts
+++ b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils.ts
@@ -25,8 +25,8 @@ export const convertToBytes = (size: number, unit: StorageSizeUnits = StorageSiz
return size * Math.pow(k, i)
}
-export function getConnectionURL(projectRef: string, endpoint?: string) {
- const projUrl = endpoint ? `https://${endpoint}` : `https://${projectRef}.supabase.co`
+export function getConnectionURL(projectRef: string, protocol: string, endpoint?: string) {
+ const projUrl = endpoint ? `${protocol}://${endpoint}` : `https://${projectRef}.supabase.co`
const url = new URL(projUrl)
url.pathname = '/storage/v1/s3'
diff --git a/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx b/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx
index cb9929f26f1..e4ffdb9ad79 100644
--- a/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx
+++ b/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx
@@ -30,7 +30,9 @@ const DisplayConfigSettings = () => {
jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated
const jwtSecret = config?.jwt_secret ?? ''
- const apiUrl = `https://${settings?.app_config?.endpoint ?? '-'}`
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const endpoint = settings?.app_config?.endpoint
+ const apiUrl = endpoint ? `${protocol}://${endpoint}` : '-'
return (
<ConfigContentWrapper>
diff --git a/apps/studio/data/auth/user-create-mutation.ts b/apps/studio/data/auth/user-create-mutation.ts
index 08e60d7e962..4484f199cc7 100644
--- a/apps/studio/data/auth/user-create-mutation.ts
+++ b/apps/studio/data/auth/user-create-mutation.ts
@@ -1,11 +1,12 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
-import { useFlag } from 'hooks/ui/useFlag'
+import { sqlKeys } from 'data/sql/keys'
import { post } from 'lib/common/fetch'
+import { IS_PLATFORM } from 'lib/constants'
+import { PROJECT_ENDPOINT_PROTOCOL } from 'pages/api/constants'
import type { ResponseError } from 'types'
import { authKeys } from './keys'
-import { sqlKeys } from 'data/sql/keys'
export type UserCreateVariables = {
projectRef?: string
diff --git a/apps/studio/data/auth/user-update-mutation.ts b/apps/studio/data/auth/user-update-mutation.ts
index 776462ddece..d6f2e5a7623 100644
--- a/apps/studio/data/auth/user-update-mutation.ts
+++ b/apps/studio/data/auth/user-update-mutation.ts
@@ -1,8 +1,9 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
-import { useFlag } from 'hooks/ui/useFlag'
import { put } from 'lib/common/fetch'
+import { IS_PLATFORM } from 'lib/constants'
+import { PROJECT_ENDPOINT_PROTOCOL } from 'pages/api/constants'
import type { ResponseError } from 'types'
import { authKeys } from './keys'
diff --git a/apps/studio/data/config/project-settings-v2-query.ts b/apps/studio/data/config/project-settings-v2-query.ts
index 129d756c0bd..50d04c0e25c 100644
--- a/apps/studio/data/config/project-settings-v2-query.ts
+++ b/apps/studio/data/config/project-settings-v2-query.ts
@@ -8,7 +8,12 @@ import type { ResponseError } from 'types'
import { configKeys } from './keys'
export type ProjectSettingsVariables = { projectRef?: string }
-export type ProjectSettings = components['schemas']['ProjectSettingsResponse']
+
+// Manually add the protocol property to the response - specifically just for the local/CLI environment
+type ProjectAppConfig = components['schemas']['ProjectAppConfigResponse'] & { protocol?: string }
+export type ProjectSettings = components['schemas']['ProjectSettingsResponse'] & {
+ app_config?: ProjectAppConfig
+}
export async function getProjectSettings(
{ projectRef }: ProjectSettingsVariables,
diff --git a/apps/studio/data/telemetry/send-event-mutation.ts b/apps/studio/data/telemetry/send-event-mutation.ts
index 893f724a5ec..3462905c476 100644
--- a/apps/studio/data/telemetry/send-event-mutation.ts
+++ b/apps/studio/data/telemetry/send-event-mutation.ts
@@ -3,6 +3,7 @@ import { components } from 'api-types'
import { isBrowser, LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
@@ -23,7 +24,7 @@ export async function sendEvent({ body }: { body: SendEventPayload }) {
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/event`, { body, headers })
diff --git a/apps/studio/data/telemetry/send-groups-identify-mutation.ts b/apps/studio/data/telemetry/send-groups-identify-mutation.ts
index 98f636ff34f..6ad7e4a534c 100644
--- a/apps/studio/data/telemetry/send-groups-identify-mutation.ts
+++ b/apps/studio/data/telemetry/send-groups-identify-mutation.ts
@@ -3,6 +3,7 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { components } from 'api-types'
import { LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError } from 'types'
export type SendGroupsIdentifyVariables = components['schemas']['TelemetryGroupsIdentityBody']
@@ -13,7 +14,7 @@ export async function sendGroupsIdentify({ body }: { body: SendGroupsIdentifyVar
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const { data, error } = await post(`/platform/telemetry/groups/identify`, {
body,
diff --git a/apps/studio/data/telemetry/send-groups-reset-mutation.ts b/apps/studio/data/telemetry/send-groups-reset-mutation.ts
index 586e4b5982b..28805372b52 100644
--- a/apps/studio/data/telemetry/send-groups-reset-mutation.ts
+++ b/apps/studio/data/telemetry/send-groups-reset-mutation.ts
@@ -3,6 +3,7 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { components } from 'api-types'
import { LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError } from 'types'
export type SendGroupsResetVariables = components['schemas']['TelemetryGroupsResetBody']
@@ -13,7 +14,7 @@ export async function sendGroupsReset({ body }: { body: SendGroupsResetVariables
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const { data, error } = await post(`/platform/telemetry/groups/reset`, {
body,
diff --git a/apps/studio/data/telemetry/send-identify-mutation.ts b/apps/studio/data/telemetry/send-identify-mutation.ts
index 640ddf51b45..3d64cc2c899 100644
--- a/apps/studio/data/telemetry/send-identify-mutation.ts
+++ b/apps/studio/data/telemetry/send-identify-mutation.ts
@@ -4,6 +4,7 @@ import { components } from 'api-types'
import { LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
import { Profile } from 'data/profile/types'
+import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError } from 'types'
type SendIdentify = components['schemas']['TelemetryIdentifyBodyV2']
@@ -22,7 +23,7 @@ export async function sendIdentify({ body }: { body: SendIdentifyPayload }) {
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/identify`, { body, headers })
diff --git a/apps/studio/data/telemetry/send-page-leave-mutation.ts b/apps/studio/data/telemetry/send-page-leave-mutation.ts
index d813dff1c2e..97d3b7cf9e0 100644
--- a/apps/studio/data/telemetry/send-page-leave-mutation.ts
+++ b/apps/studio/data/telemetry/send-page-leave-mutation.ts
@@ -3,6 +3,7 @@ import { components } from 'api-types'
import { LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
@@ -14,7 +15,7 @@ export async function sendPageLeave({ body }: { body: SendPageLeaveBody }) {
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const { data, error } = await post(`/platform/telemetry/page-leave`, {
body,
diff --git a/apps/studio/data/telemetry/send-page-mutation.ts b/apps/studio/data/telemetry/send-page-mutation.ts
index d85e13fb6f6..498b83af048 100644
--- a/apps/studio/data/telemetry/send-page-mutation.ts
+++ b/apps/studio/data/telemetry/send-page-mutation.ts
@@ -3,6 +3,7 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { components } from 'api-types'
import { isBrowser, LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
@@ -20,7 +21,7 @@ export async function sendPage({ body }: { body: SendPagePayload }) {
? localStorage.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
: null) === 'true'
- if (!consent) return undefined
+ if (!consent || !IS_PLATFORM) return undefined
const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/page`, { body, headers })
diff --git a/apps/studio/data/telemetry/send-reset-mutation.ts b/apps/studio/data/telemetry/send-reset-mutation.ts
index 070824b9f67..73ce7964570 100644
--- a/apps/studio/data/telemetry/send-reset-mutation.ts
+++ b/apps/studio/data/telemetry/send-reset-mutation.ts
@@ -1,9 +1,12 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { handleError, post } from 'data/fetchers'
+import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError } from 'types'
export async function sendReset() {
+ if (!IS_PLATFORM) return undefined
+
const { data, error } = await post(`/platform/telemetry/reset`, {})
if (error) handleError(error)
return data
diff --git a/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx b/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
index 24e60285183..7ba14a0c7cb 100644
--- a/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
+++ b/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx
@@ -42,9 +42,9 @@ import { Bucket } from 'data/storage/buckets-query'
import { moveStorageObject } from 'data/storage/object-move-mutation'
import { IS_PLATFORM } from 'lib/constants'
import { lookupMime } from 'lib/mime'
-import { PROJECT_ENDPOINT_PROTOCOL } from 'pages/api/constants'
-import { Button, SONNER_DEFAULT_DURATION, SonnerProgress } from 'ui'
import Link from 'next/link'
+import { Button, SONNER_DEFAULT_DURATION, SonnerProgress } from 'ui'
+import { PROJECT_ENDPOINT_PROTOCOL } from 'pages/api/constants'
type CachedFile = { id: string; fetchedAt: number; expiresIn: number; url: string }
@@ -128,12 +128,7 @@ class StorageExplorerStore {
}
}
- initStore(
- projectRef: string,
- url: string,
- serviceKey: string,
- protocol: string = PROJECT_ENDPOINT_PROTOCOL
- ) {
+ initStore(projectRef: string, url: string, serviceKey: string, protocol: string) {
this.projectRef = projectRef
this.resumableUploadUrl = `${IS_PLATFORM ? 'https' : protocol}://${url}/storage/v1/upload/resumable`
this.serviceKey = serviceKey
diff --git a/apps/studio/pages/api/projects/[ref]/settings.ts b/apps/studio/pages/api/projects/[ref]/settings.ts
index f80694a590a..ef989bf4b1e 100644
--- a/apps/studio/pages/api/projects/[ref]/settings.ts
+++ b/apps/studio/pages/api/projects/[ref]/settings.ts
@@ -2,6 +2,12 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { components } from 'api-types'
import apiWrapper from 'lib/api/apiWrapper'
+import { PROJECT_ENDPOINT, PROJECT_ENDPOINT_PROTOCOL } from 'pages/api/constants'
+
+type ProjectAppConfig = components['schemas']['ProjectAppConfigResponse'] & { protocol?: string }
+export type ProjectSettings = components['schemas']['ProjectSettingsResponse'] & {
+ app_config?: ProjectAppConfig
+}
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -18,16 +24,17 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
}
const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
- // Platform specific endpoint
- const response: components['schemas']['ProjectSettingsResponse'] = {
+ const response: ProjectSettings = {
app_config: {
db_schema: 'public',
- endpoint: '',
+ endpoint: PROJECT_ENDPOINT,
+ // manually added to force the frontend to use the correct URL
+ protocol: PROJECT_ENDPOINT_PROTOCOL,
},
cloud_provider: 'AWS',
- db_dns_name: '',
+ db_dns_name: '-',
db_host: 'localhost',
- dp_ip_addr_config: '',
+ dp_ip_addr_config: 'legacy' as const,
db_name: 'postgres',
// @ts-expect-error API is typed wrongly
db_port: 5432,
diff --git a/apps/studio/pages/project/[ref]/api/index.tsx b/apps/studio/pages/project/[ref]/api/index.tsx
index a693135da06..db96b907935 100644
--- a/apps/studio/pages/project/[ref]/api/index.tsx
+++ b/apps/studio/pages/project/[ref]/api/index.tsx
@@ -37,10 +37,12 @@ const DocView = () => {
const refreshDocs = async () => await refetch()
+ const protocol = settings?.app_config?.protocol ?? 'https'
+ const hostEndpoint = settings?.app_config?.endpoint
const endpoint =
customDomainData?.customDomain?.status === 'active'
? `https://${customDomainData.customDomain?.hostname}`
- : `https://${settings?.app_config?.endpoint ?? '-'}`
+ : `${protocol}://${hostEndpoint ?? '-'}`
const { paths } = jsonSchema || {}
const PAGE_KEY: any = resource || rpc || page || 'index'