import type { IUserLogoutData } from "#shared/types"; import { clearNewApiAuthCookies, createSuccessResponse, newApiAuthedFetch } from "~~/server/utils"; export default defineEventHandler(async (event) => { try { // 带上本站 httpOnly cookie 中的 NewAPI 登录态,请求上游销毁 session。 await newApiAuthedFetch(event, "/api/user/logout", { method: "GET" }); } catch { // 上游 session 可能已失效,本地仍然必须清理,避免残留坏登录态。 } finally { clearNewApiAuthCookies(event); } return createSuccessResponse(null, "登出成功"); });