The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): thread auth headers through getReadReplicas (#49327)
Charisda1a3ae9484e
diff --git a/apps/studio/data/read-replicas/replicas-query.test.ts b/apps/studio/data/read-replicas/replicas-query.test.tsindex 9be3be7f40e..3b9b19bf0b9 100644--- a/apps/studio/data/read-replicas/replicas-query.test.ts+++ b/apps/studio/data/read-replicas/replicas-query.test.ts@@ -1,10 +1,13 @@+import { HttpResponse } from 'msw'import { describe, expect, it } from 'vitest'import {getMaxReplicas,+ getReadReplicas,READ_REPLICA_COMPUTE_CAPS,READ_REPLICAS_MAX_COUNT,} from './replicas-query'+import { addAPIMock } from '@/tests/lib/msw'describe('getMaxReplicas', () => {it('returns 0 for ineligible compute sizes (pico, nano, micro)', () => {@@ -46,3 +49,24 @@ describe('getMaxReplicas', () => {}})})++describe('getReadReplicas', () => {+ it('forwards the given headers on the request', async () => {+ let receivedAuthHeader: string | null = null++ addAPIMock({+ method: 'get',+ path: '/platform/projects/:ref/databases',+ response: ({ request }) => {+ receivedAuthHeader = request.headers.get('Authorization')+ return HttpResponse.json([])+ },+ })++ await getReadReplicas({ projectRef: 'default' }, undefined, {+ Authorization: 'Bearer test-token',+ })++ expect(receivedAuthHeader).toBe('Bearer test-token')+ })+})diff --git a/apps/studio/data/read-replicas/replicas-query.ts b/apps/studio/data/read-replicas/replicas-query.tsindex c262d41c335..3a9b2a1771f 100644--- a/apps/studio/data/read-replicas/replicas-query.ts+++ b/apps/studio/data/read-replicas/replicas-query.ts@@ -33,11 +33,16 @@ export type ReadReplicasVariables = {export type Database = components['schemas']['DatabaseDetailResponse']-export async function getReadReplicas({ projectRef }: ReadReplicasVariables, signal?: AbortSignal) {+export async function getReadReplicas(+ { projectRef }: ReadReplicasVariables,+ signal?: AbortSignal,+ headers?: HeadersInit+) {if (!projectRef) throw new Error('Project ref is required')const { data, error } = await get(`/platform/projects/{ref}/databases`, {params: { path: { ref: projectRef } },+ headers,signal,})