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 适合在边缘执行轻量鉴权与预处理,降低后端压力并提升响应速度。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部