Skip to content

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

update anon key access

Alaister Youngf32d6926efc9
diff --git a/studio/components/interfaces/Functions/TerminalInstructions.tsx b/studio/components/interfaces/Functions/TerminalInstructions.tsx
index db17da57b61..f8f30b523ab 100644
--- a/studio/components/interfaces/Functions/TerminalInstructions.tsx
+++ b/studio/components/interfaces/Functions/TerminalInstructions.tsx
@@ -23,8 +23,10 @@ const TerminalInstructions: FC<Props> = ({ closable = false }) => {
const { data: settings } = useProjectApiQuery({
projectRef,
})
-
- const anonKey = settings?.autoApiService.defaultApiKey
+ const apiService = settings?.autoApiService
+ const anonKey = apiService?.service_api_keys.find((x) => x.name === 'anon key')
+ ? apiService.defaultApiKey
+ : undefined
const endpoint = settings?.autoApiService.app_config.endpoint ?? ''
const endpointSections = endpoint.split('.')
diff --git a/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx b/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
index 03ff21362d8..a2fc1baf0dd 100644
--- a/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
+++ b/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx
@@ -47,7 +47,7 @@ const APIKeys = () => {
jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated
const apiUrl = `${apiService?.protocol ?? 'https'}://${apiService?.endpoint ?? '-'}`
- const anonKey = apiKeys.find((key: any) => key.tags === 'anon')
+ const anonKey = apiKeys.find((key) => key.tags === 'anon')
const clientInitSnippet: any = Snippets.init(apiUrl)
const selectedLanguageSnippet =
diff --git a/studio/pages/project/[ref]/functions/[id]/details.tsx b/studio/pages/project/[ref]/functions/[id]/details.tsx
index e1bf573e148..613833e4f31 100644
--- a/studio/pages/project/[ref]/functions/[id]/details.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/details.tsx
@@ -99,9 +99,12 @@ const PageLayout: NextPageWithLayout = () => {
]
// Get the API service
- const anonKey = settings?.autoApiService.defaultApiKey
+ const apiService = settings?.autoApiService
+ const anonKey = apiService?.service_api_keys.find((x) => x.name === 'anon key')
+ ? apiService.defaultApiKey
+ : undefined
- const endpoint = settings?.autoApiService.app_config.endpoint ?? ''
+ const endpoint = apiService?.app_config.endpoint ?? ''
const endpointSections = endpoint.split('.')
const functionsEndpoint = [
...endpointSections.slice(0, 1),