Merge pull request #8757 from supabase/chore/fix-functions-urls

Swap .co for .net
This commit is contained in:
Terry Sutton authored and GitHub committed 2022-09-08 11:00:33 -02:30
commit dbeadc34d6
3 files changed
+17 -4

No files matched your search

@@ -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.co/${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>
@@ -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.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',
@@ -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',