Supabase Edge Functions 与鉴权实践// index.ts (Deno)
Deno.serve(async (req) => {
const auth = req.headers.get('authorization') || ''
if (!auth.startsWith('Bearer ')) {
return new Response('Unauthorized', { status: 401 })
}
// 业务处理
return new Response(JSON.stringify({ ok: true }), {
headers: { 'content-type': 'application/json' }
})
})
部署与调用使用 `supabase functions deploy` 部署,前端以 `Authorization: Bearer <token>` 调用总结Edge Functions 适合在边缘执行轻量鉴权与预处理,降低后端压力并提升响应速度。

发表评论 取消回复