Skip to content

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

Get the TLD from the UI store

Terry Sutton4c5ae11b3dc2
diff --git a/studio/components/interfaces/Functions/FunctionsListItem.tsx b/studio/components/interfaces/Functions/FunctionsListItem.tsx
index 9fd0de9089f..f2b9045d417 100644
--- a/studio/components/interfaces/Functions/FunctionsListItem.tsx
+++ b/studio/components/interfaces/Functions/FunctionsListItem.tsx
@@ -17,6 +17,10 @@ const FunctionsListItem: FC<Props> = ({ function: item }) => {
const router = useRouter()
const ref = ui?.selectedProject?.ref
+ // get the .co or .net TLD from the restUrl
+ const restUrl = ui.selectedProject?.restUrl
+ const restUrlTld = new URL(restUrl as string).hostname.split('.').pop()
+
return (
<Table.tr
key={item.id}
@@ -31,7 +35,7 @@ const FunctionsListItem: FC<Props> = ({ function: item }) => {
</Table.td>
<Table.td className="">
<div className="text-xs text-scale-900 flex gap-2 items-center truncate">
- <span className="font-mono truncate hidden md:inline">{`https://${ref}.functions.supabase.net/${item.slug}`}</span>
+ <span className="font-mono truncate hidden md:inline">{`https://${ref}.functions.supabase.${restUrlTld}/${item.slug}`}</span>
<span className="font-mono truncate md:hidden">{`/${item.name}`}</span>
</div>
</Table.td>
diff --git a/studio/components/interfaces/Functions/TerminalInstructions.tsx b/studio/components/interfaces/Functions/TerminalInstructions.tsx
index 1fa95d55a4f..ead46f004d5 100644
--- a/studio/components/interfaces/Functions/TerminalInstructions.tsx
+++ b/studio/components/interfaces/Functions/TerminalInstructions.tsx
@@ -1,11 +1,11 @@
import { useRouter } from 'next/router'
import { Button, IconTerminal, IconMaximize2, IconMinimize2 } from '@supabase/ui'
-
import { useProjectSettings } from 'hooks'
import { useAccessTokens } from 'hooks/queries/useAccessTokens'
import { Commands } from './Functions.types'
import CommandRender from 'components/interfaces/Functions/CommandRender'
import { FC, useState } from 'react'
+import { useStore } from 'hooks'
interface Props {
closable?: boolean
@@ -14,6 +14,7 @@ interface Props {
const TerminalInstructions: FC<Props> = ({ closable = false }) => {
const router = useRouter()
const { ref } = router.query
+ const { ui } = useStore()
const { tokens } = useAccessTokens()
const { services } = useProjectSettings(ref as string | undefined)
@@ -34,6 +35,10 @@ const TerminalInstructions: FC<Props> = ({ closable = false }) => {
...endpointSections.slice(1),
].join('.')
+ // get the .co or .net TLD from the restUrl
+ const restUrl = ui.selectedProject?.restUrl
+ const restUrlTld = new URL(restUrl as string).hostname.split('.').pop()
+
const commands: Commands[] = [
{
command: 'supabase functions new hello-world',
@@ -61,7 +66,7 @@ const TerminalInstructions: FC<Props> = ({ closable = false }) => {
comment: 'Deploy your function',
},
{
- command: `curl -L -X POST 'https://${ref}.functions.supabase.net/hello-world' -H 'Authorization: Bearer ${
+ command: `curl -L -X POST 'https://${ref}.functions.supabase.${restUrlTld}/hello-world' -H 'Authorization: Bearer ${
anonKey ?? '[YOUR ANON KEY]'
}' --data '{"name":"Functions"}'`,
description: 'Invokes the hello-world function',
diff --git a/studio/pages/project/[ref]/functions/[id]/details.tsx b/studio/pages/project/[ref]/functions/[id]/details.tsx
index ae66b874224..54118e02a2e 100644
--- a/studio/pages/project/[ref]/functions/[id]/details.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/details.tsx
@@ -23,6 +23,10 @@ const PageLayout: NextPageWithLayout = () => {
setSelectedFunction(functions.byId(id))
}, [functions.isLoaded, ui.selectedProject])
+ // get the .co or .net TLD from the restUrl
+ const restUrl = ui.selectedProject?.restUrl
+ const restUrlTld = new URL(restUrl as string).hostname.split('.').pop()
+
const managementCommands: any = [
{
command: `supabase functions deploy ${selectedFunction?.slug}`,
@@ -110,7 +114,7 @@ const PageLayout: NextPageWithLayout = () => {
const invokeCommands: any = [
{
- command: `curl -L -X POST 'https://${ref}.functions.supabase.net/${
+ command: `curl -L -X POST 'https://${ref}.functions.supabase.${restUrlTld}/${
selectedFunction?.slug
}' -H 'Authorization: Bearer ${anonKey ?? '[YOUR ANON KEY]'}' --data '{"name":"Functions"}'`,
description: 'Invokes the hello function',