Context
In this example, we use Composable Function's context to authorize a specific header.
const schema = z.object({ email: z.string().min(1).email() })
const contextSchema = z.object({
customHeader: z.string({ invalid_type_error: 'Missing custom header' }),
})
const mutation = applySchema(
schema,
contextSchema,
)(async (values) => values)
export const action = async ({ request }: Route.ActionArgs) => {
return formAction({
request,
schema,
mutation,
context: { customHeader: request.headers.get('customHeader') },
})
}
export default () => <SchemaForm schema={schema} />