feat: 大量优化和bug修复
This commit is contained in:
@@ -20,8 +20,11 @@ export default defineEventHandler(async (event) => {
|
||||
// 只处理 /api/ 路径
|
||||
if (!pathname.startsWith("/api/")) return;
|
||||
|
||||
// OPTIONS 预检请求不需要鉴权,CORS headers 由 nuxt.config routeRules 统一设置
|
||||
if (method === "OPTIONS") return;
|
||||
// OPTIONS 预检请求不需要鉴权;直接返回 204,避免没有匹配 API 路由时落到 404。
|
||||
if (method === "OPTIONS") {
|
||||
setResponseStatus(event, 204);
|
||||
return "";
|
||||
}
|
||||
|
||||
// 公开路由直接放行
|
||||
if (isPublicApiRoute(pathname, method)) return;
|
||||
|
||||
Reference in New Issue
Block a user