auth
关于 auth
在 tRPC 中实现 JWT/cookie 认证与授权:使用 createContext 提取用户,用 t.middleware 配合 opts.next({ ctx }) 将上下文收窄为非空 user,采用 protectedProcedure 基础模式,客户端通过 httpBatchLink 的 headers() 设置 Authorization 头,使用 WebSocket 的 connectionParams,以及通过 cookie 或 EventSource polyfill 自定义头实现 SSE 认证。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / trpc/ trpc --skill auth安装后在 Claude Code 中输入/auth确认已加载。
评论
支持 Markdown