Files
OCS_service/server/api/auth/[...all].ts
T
2026-05-22 22:38:01 +08:00

15 lines
506 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// server/api/auth/[...all].ts - Better Auth catch-all 路由,处理所有 /api/auth/* 请求
import { toWebRequest } from "h3";
import { auth } from "~~/server/utils/auth";
/**
* 将所有 /api/auth/* 请求转发给 Better Auth handler
*
* toWebRequest 把 Nitro H3Event 转为标准 Web API Request
* Better Auth handler 返回标准 Web API ResponseNitro 会自动将其转发给客户端
*/
export default defineEventHandler((event) => {
return auth.handler(toWebRequest(event));
});