Files
supabase/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.constants.ts
Ali Waseem a45e6cf333 fix: remove _DEFAULT from connect menu env var names (#44462)
## Summary

Removes `_DEFAULT` from the publishable key env var name across all
Connect and ConnectSheet framework content, so that e.g.
`NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY` becomes
`NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`. This matches the docs and sample
apps.

### Connect

- Next.js (App Router)
- Next.js (Pages Router)
- React (Create React App)
- React (Vite)
- Remix
- SolidJS
- SvelteKit

### ConnectSheet

- Next.js (App Router)
- Next.js (Pages Router)
- React (Create React App)
- React (Vite)
- Remix
- SolidJS
- SvelteKit
- Vue.js
- shadcn env step

Resolves FE-2934

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Standardized environment variable names in generated connection/setup
instructions: when a publishable key is present the templates now
reference the publishable env var (e.g.,
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY, VITE_SUPABASE_PUBLISHABLE_KEY,
REACT_APP_SUPABASE_PUBLISHABLE_KEY, etc.) with unchanged anon-key
fallback behavior.
* Updated cURL/tab placeholders to reflect the new publishable-key
identifier when hiding keys.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-09 13:23:21 +00:00

83 lines
2.2 KiB
TypeScript

interface InvocationTab {
id: string
label: string
language: 'bash' | 'js' | 'ts' | 'dart' | 'python'
hideLineNumbers?: boolean
code: (props: {
showKey: boolean
functionUrl: string
functionName: string
apiKey: string
}) => string
}
export const INVOCATION_TABS: InvocationTab[] = [
{
id: 'curl',
label: 'cURL',
language: 'bash',
code: ({ showKey, functionUrl, apiKey }) => {
const obfuscatedName = apiKey.includes('publishable')
? 'SUPABASE_PUBLISHABLE_KEY'
: 'SUPABASE_ANON_KEY'
const keyValue = showKey ? apiKey : obfuscatedName
return `curl -L -X POST '${functionUrl}' \\
-H 'Authorization: Bearer ${keyValue}' \\${apiKey.includes('publishable') ? `\n -H 'apikey: ${keyValue}' \\` : ''}
-H 'Content-Type: application/json' \\
--data '{"name":"Functions"}'`
},
},
{
id: 'supabase-js',
label: 'JavaScript',
language: 'js',
hideLineNumbers: true,
code: ({ functionName }) => `import { createClient } from '@supabase/supabase-js'
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)
const { data, error } = await supabase.functions.invoke('${functionName}', {
body: { name: 'Functions' },
})`,
},
{
id: 'swift',
label: 'Swift',
language: 'ts',
hideLineNumbers: true,
code: ({ functionName }) => `struct Response: Decodable {
// Expected response definition
}
let response: Response = try await supabase.functions
.invoke(
"${functionName}",
options: FunctionInvokeOptions(
body: ["name": "Functions"]
)
)`,
},
{
id: 'flutter',
label: 'Flutter',
language: 'dart',
hideLineNumbers: true,
code: ({
functionName,
}) => `final res = await supabase.functions.invoke('${functionName}', body: {'name': 'Functions'});
final data = res.data;`,
},
{
id: 'python',
label: 'Python',
language: 'python',
hideLineNumbers: true,
code: ({ functionName }) => `response = supabase.functions.invoke(
"${functionName}",
invoke_options={"body": {"name": "Functions"}}
)`,
},
]
export const HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as const