Skip to content

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

fix: Refactor the host calculation logic for the realtime inspector (#21689)

Ivan Vasilov0942bfee87a3
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts b/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
index d81c168af4f..9dd8a914613 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
+++ b/apps/studio/components/interfaces/Realtime/Inspector/useRealtimeMessages.ts
@@ -64,16 +64,12 @@ export const useRealtimeMessages = ({
enableDbChanges,
enableBroadcast,
}: RealtimeConfig) => {
+ const { data } = useProjectApiQuery({ projectRef: projectRef })
+
// the default host is prod until the correct one comes through an API call.
- const [host, setHost] = useState(`https://${projectRef}.supabase.co`)
- useProjectApiQuery(
- { projectRef: projectRef },
- {
- onSuccess: (data) => {
- setHost(`${data.autoApiService.protocol}://${data.autoApiService.endpoint}`)
- },
- }
- )
+ const host = data
+ ? `${data.autoApiService.protocol}://${data.autoApiService.endpoint}`
+ : `https://${projectRef}.supabase.co`
const [logData, dispatch] = useReducer(reducer, [] as LogData[])
const pushMessage = (messageType: string, metadata: any) => {