Skip to content

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

fix: Remove auth from `/incident-status` and `/incident-banner` endpoints (#43751)

Ivan Vasilovc5b669538096
diff --git a/apps/studio/data/platform/incident-banner-query.ts b/apps/studio/data/platform/incident-banner-query.ts
index f0b6a4babbb..9832c8833d1 100644
--- a/apps/studio/data/platform/incident-banner-query.ts
+++ b/apps/studio/data/platform/incident-banner-query.ts
@@ -1,5 +1,5 @@
import { queryOptions } from '@tanstack/react-query'
-import { getAccessToken, IS_PLATFORM } from 'common'
+import { IS_PLATFORM } from 'common'
import { platformKeys } from './keys'
import { BASE_PATH } from '@/lib/constants'
@@ -18,11 +18,10 @@ export type IncidentBannerData = { incidents: Array<IncidentBannerItem> }
export type IncidentBannerError = unknown
async function getIncidentBanner(signal?: AbortSignal): Promise<IncidentBannerData> {
- const accessToken = await getAccessToken()
const response = await fetch(`${BASE_PATH}/api/incident-banner`, {
signal,
method: 'GET',
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` },
+ headers: { 'Content-Type': 'application/json' },
})
if (!response.ok) throw new Error(`Failed to fetch incident banner: ${response.statusText}`)
return response.json()
diff --git a/apps/studio/data/platform/incident-status-query.ts b/apps/studio/data/platform/incident-status-query.ts
index a7e1e907f79..7c767fc1cb5 100644
--- a/apps/studio/data/platform/incident-status-query.ts
+++ b/apps/studio/data/platform/incident-status-query.ts
@@ -1,5 +1,4 @@
import { useQuery } from '@tanstack/react-query'
-import { getAccessToken } from 'common'
import type { IncidentInfo } from 'lib/api/incident-status'
import { BASE_PATH, IS_PLATFORM, IS_TEST_ENV } from 'lib/constants'
import { partition } from 'lodash'
@@ -10,13 +9,11 @@ import { platformKeys } from './keys'
export async function getIncidentStatus(
signal?: AbortSignal
): Promise<{ maintenanceEvents: IncidentInfo[]; incidents: IncidentInfo[] }> {
- const accessToken = await getAccessToken()
const response = await fetch(`${BASE_PATH}/api/incident-status`, {
signal,
method: 'GET',
headers: {
'Content-Type': 'application/json',
- Authorization: `Bearer ${accessToken}`,
},
})
diff --git a/apps/studio/lib/api/apiWrapper.ts b/apps/studio/lib/api/apiWrapper.ts
index eb749ffc007..343e64b55c8 100644
--- a/apps/studio/lib/api/apiWrapper.ts
+++ b/apps/studio/lib/api/apiWrapper.ts
@@ -24,7 +24,7 @@ export function isResponseOk<T>(response: T | ResponseFailure | undefined): resp
// Purpose of this apiWrapper is to function like a global catchall for ANY errors
// It's a safety net as the API service should never drop, nor fail
-export default async function apiWrapper(
+async function apiWrapper(
req: NextApiRequest,
res: NextApiResponse,
handler: (
@@ -55,3 +55,6 @@ export default async function apiWrapper(
return res.status(500).json({ error })
}
}
+
+export { apiWrapper }
+export default apiWrapper
diff --git a/apps/studio/pages/api/incident-banner.ts b/apps/studio/pages/api/incident-banner.ts
index 7dc2f22aa0c..8cf0cafc265 100644
--- a/apps/studio/pages/api/incident-banner.ts
+++ b/apps/studio/pages/api/incident-banner.ts
@@ -2,7 +2,6 @@ import { createHash } from 'crypto'
import { IS_PLATFORM, IS_PROD } from 'common'
import { NextApiRequest, NextApiResponse } from 'next'
import { z } from 'zod'
-import apiWrapper from 'lib/api/apiWrapper'
const INCIDENT_IO_BASE_URL = 'https://api.incident.io/v2'
@@ -157,7 +156,4 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return res.status(200).json({ incidents: bannerIncidents })
}
-const wrapper = (req: NextApiRequest, res: NextApiResponse) =>
- apiWrapper(req, res, handler, { withAuth: true })
-
-export default wrapper
+export default handler
diff --git a/apps/studio/pages/api/incident-status.ts b/apps/studio/pages/api/incident-status.ts
index 9c61c8c2542..43b38a9e280 100644
--- a/apps/studio/pages/api/incident-status.ts
+++ b/apps/studio/pages/api/incident-status.ts
@@ -8,7 +8,6 @@ import {
type IncidentInfo,
} from '@/lib/api/incident-status'
import { createAdminClient } from '@/lib/api/supabase-admin'
-import apiWrapper from 'lib/api/apiWrapper'
/**
* Cache on browser for 5 minutes
@@ -98,7 +97,4 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
}
}
-const wrapper = (req: NextApiRequest, res: NextApiResponse) =>
- apiWrapper(req, res, handler, { withAuth: true })
-
-export default wrapper
+export default handler