Skip to content

Commit fbef43f

Browse files
itslennyjoshenlim
andauthored
fix: use storage endpoint in S3 settings (supabase#37469)
* fix: use storage endpoint in S3 settings * Update retrieval of endpoint for analytics bucket related components --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent e7aef7f commit fbef43f

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

apps/studio/components/interfaces/Storage/AnalyticBucketDetails/SimpleConfigurationDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const SimpleConfigurationDetails = ({ bucketName }: { bucketName: string
2424
const { data: apiKeys } = useAPIKeysQuery({ projectRef: project?.ref })
2525
const { data: settings } = useProjectSettingsV2Query({ projectRef: project?.ref })
2626
const protocol = settings?.app_config?.protocol ?? 'https'
27-
const endpoint = settings?.app_config?.endpoint
27+
const endpoint = settings?.app_config?.storage_endpoint || settings?.app_config?.endpoint
2828

2929
const { serviceKey } = getKeys(apiKeys)
3030
const serviceApiKey = serviceKey?.api_key ?? 'SUPABASE_CLIENT_SERVICE_KEY'

apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const S3Connection = () => {
8080
})
8181

8282
const protocol = settings?.app_config?.protocol ?? 'https'
83-
const endpoint = settings?.app_config?.endpoint
83+
const endpoint = settings?.app_config?.storage_endpoint || settings?.app_config?.endpoint
8484
const hasStorageCreds = storageCreds?.data && storageCreds.data.length > 0
8585
const s3connectionUrl = getConnectionURL(projectRef ?? '', protocol, endpoint)
8686

apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export const convertToBytes = (size: number, unit: StorageSizeUnits = StorageSiz
2626
}
2727

2828
function getStorageURL(projectRef: string, protocol: string, endpoint?: string) {
29-
const projUrl = endpoint ? `${protocol}://${endpoint}` : `https://${projectRef}.supabase.co`
29+
const projUrl = endpoint
30+
? `${protocol}://${endpoint}`
31+
: `https://${projectRef}.storage.supabase.co`
3032
const url = new URL(projUrl)
3133
return url
3234
}

apps/studio/data/storage/iceberg-wrapper-create-mutation.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PermissionAction } from '@supabase/shared-types/out/constants'
2+
import { snakeCase } from 'lodash'
23

34
import { WRAPPERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'
45
import {
@@ -8,10 +9,8 @@ import {
89
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
910
import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query'
1011
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
11-
import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query'
1212
import { FDWCreateVariables, useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'
1313
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
14-
import { snakeCase } from 'lodash'
1514
import { useS3AccessKeyCreateMutation } from './s3-access-key-create-mutation'
1615

1716
export const useIcebergWrapperCreateMutation = () => {
@@ -22,16 +21,14 @@ export const useIcebergWrapperCreateMutation = () => {
2221

2322
const { data: settings } = useProjectSettingsV2Query({ projectRef: project?.ref })
2423
const protocol = settings?.app_config?.protocol ?? 'https'
25-
const endpoint = settings?.app_config?.endpoint
24+
const endpoint = settings?.app_config?.storage_endpoint || settings?.app_config?.endpoint
2625

2726
const apiKey = secretKey?.api_key ?? serviceKey?.api_key ?? 'SUPABASE_CLIENT_API_KEY'
2827

2928
const wrapperMeta = WRAPPERS.find((wrapper) => wrapper.name === 'iceberg_wrapper')
3029

3130
const canCreateCredentials = useCheckPermissions(PermissionAction.STORAGE_ADMIN_WRITE, '*')
3231

33-
const { data: config } = useProjectStorageConfigQuery({ projectRef: project?.ref })
34-
3532
const { mutateAsync: createS3AccessKey, isLoading: isCreatingS3AccessKey } =
3633
useS3AccessKeyCreateMutation()
3734

apps/studio/pages/api/platform/projects/[ref]/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
3030
app_config: {
3131
db_schema: 'public',
3232
endpoint: PROJECT_ENDPOINT,
33+
storage_endpoint: PROJECT_ENDPOINT,
3334
// manually added to force the frontend to use the correct URL
3435
protocol: PROJECT_ENDPOINT_PROTOCOL,
3536
},

packages/api-types/types/platform.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7225,6 +7225,7 @@ export interface components {
72257225
app_config?: {
72267226
db_schema: string
72277227
endpoint: string
7228+
storage_endpoint: string
72287229
}
72297230
cloud_provider: string
72307231
db_dns_name: string

0 commit comments

Comments
 (0)