From 688a25fb3109a5dde3f0dc86f30e196f7214e971 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Thu, 1 Sep 2022 16:14:07 -0230 Subject: [PATCH 1/3] Swap .co for .net --- studio/components/interfaces/Functions/TerminalInstructions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio/components/interfaces/Functions/TerminalInstructions.tsx b/studio/components/interfaces/Functions/TerminalInstructions.tsx index aa6a7f0b083..1fa95d55a4f 100644 --- a/studio/components/interfaces/Functions/TerminalInstructions.tsx +++ b/studio/components/interfaces/Functions/TerminalInstructions.tsx @@ -61,7 +61,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.net/hello-world' -H 'Authorization: Bearer ${ anonKey ?? '[YOUR ANON KEY]' }' --data '{"name":"Functions"}'`, description: 'Invokes the hello-world function', From 51dc6e0c9fd1ab4b6e41a61a65b422dcb0054775 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Thu, 1 Sep 2022 16:24:47 -0230 Subject: [PATCH 2/3] Fix list view urls --- studio/components/interfaces/Functions/FunctionsListItem.tsx | 2 +- studio/pages/project/[ref]/functions/[id]/details.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/studio/components/interfaces/Functions/FunctionsListItem.tsx b/studio/components/interfaces/Functions/FunctionsListItem.tsx index 91e871ce560..9fd0de9089f 100644 --- a/studio/components/interfaces/Functions/FunctionsListItem.tsx +++ b/studio/components/interfaces/Functions/FunctionsListItem.tsx @@ -31,7 +31,7 @@ const FunctionsListItem: FC = ({ function: item }) => {
- {`https://${ref}.functions.supabase.co/${item.slug}`} + {`https://${ref}.functions.supabase.net/${item.slug}`} {`/${item.name}`}
diff --git a/studio/pages/project/[ref]/functions/[id]/details.tsx b/studio/pages/project/[ref]/functions/[id]/details.tsx index 455358bb6b8..ae66b874224 100644 --- a/studio/pages/project/[ref]/functions/[id]/details.tsx +++ b/studio/pages/project/[ref]/functions/[id]/details.tsx @@ -110,7 +110,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.net/${ selectedFunction?.slug }' -H 'Authorization: Bearer ${anonKey ?? '[YOUR ANON KEY]'}' --data '{"name":"Functions"}'`, description: 'Invokes the hello function', From 4c5ae11b3dc2fd72b7b9b056770d147f9f9478e8 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Wed, 7 Sep 2022 12:48:00 -0230 Subject: [PATCH 3/3] Get the TLD from the UI store --- .../interfaces/Functions/FunctionsListItem.tsx | 6 +++++- .../interfaces/Functions/TerminalInstructions.tsx | 9 +++++++-- studio/pages/project/[ref]/functions/[id]/details.tsx | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) 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 = ({ 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.net/${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 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 = ({ 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.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',