diff --git a/studio/components/interfaces/Functions/FunctionsListItem.tsx b/studio/components/interfaces/Functions/FunctionsListItem.tsx index 91e871ce560..f2b9045d417 100644 --- a/studio/components/interfaces/Functions/FunctionsListItem.tsx +++ b/studio/components/interfaces/Functions/FunctionsListItem.tsx @@ -17,6 +17,10 @@ const FunctionsListItem: FC = ({ 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 ( = ({ function: item }) => {
- {`https://${ref}.functions.supabase.co/${item.slug}`} + {`https://${ref}.functions.supabase.${restUrlTld}/${item.slug}`} {`/${item.name}`}
diff --git a/studio/components/interfaces/Functions/TerminalInstructions.tsx b/studio/components/interfaces/Functions/TerminalInstructions.tsx index aa6a7f0b083..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 = ({ 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 = ({ 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 = ({ closable = false }) => { comment: 'Deploy your function', }, { - command: `curl -L -X POST 'https://${ref}.functions.supabase.co/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 455358bb6b8..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.co/${ + 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',