import { PermissionAction } from '@supabase/shared-types/out/constants' import { ChevronDown, Plus, Trash } from 'lucide-react' import { useFieldArray } from 'react-hook-form' import { useParams } from 'common' import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, FormControl_Shadcn_, FormField_Shadcn_, FormItem_Shadcn_, FormLabel_Shadcn_, FormMessage_Shadcn_, Input_Shadcn_, SheetSection, } from 'ui' import { CreateCronJobForm } from './CreateCronJobSheet/CreateCronJobSheet.constants' interface HTTPHeaderFieldsSectionProps { variant: 'edge_function' | 'http_request' } export const HTTPHeaderFieldsSection = ({ variant }: HTTPHeaderFieldsSectionProps) => { // gets the fields through form context const { fields, append, remove } = useFieldArray({ name: 'values.httpHeaders', }) const { ref } = useParams() const { can: canReadAPIKeys } = useAsyncCheckPermissions(PermissionAction.SECRETS_READ, '*') const { data: apiKeys } = useAPIKeysQuery( { projectRef: ref, reveal: true }, { enabled: canReadAPIKeys } ) const { serviceKey, secretKey } = getKeys(apiKeys) const apiKey = secretKey?.api_key ?? serviceKey?.api_key ?? '[YOUR API KEY]' return ( HTTP Headers
{fields.map((field, index) => (
( )} /> ( )} />
))}
{variant === 'edge_function' && ( { append({ name: 'Authorization', value: `Bearer ${apiKey}`, }) if (serviceKey?.type === 'secret') { append({ name: 'apikey', value: apiKey }) } }} >

Add auth header with secret key

Required if your edge function enforces JWT verification

append({ name: 'x-supabase-webhook-source', value: `[Use a secret value]`, }) } >

Add custom source header

Useful to verify that the edge function was triggered from this webhook

)}
) }