From 4121a15587613edeba4c43e9689cc24e3f9dab3d Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Sun, 21 Jun 2026 22:44:05 +0800 Subject: [PATCH] Update route.ts --- write-server/src/app/api/posts/route.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/write-server/src/app/api/posts/route.ts b/write-server/src/app/api/posts/route.ts index 1f776d1b..1b21d587 100644 --- a/write-server/src/app/api/posts/route.ts +++ b/write-server/src/app/api/posts/route.ts @@ -1,9 +1,18 @@ import { NextRequest, NextResponse } from "next/server"; import { listPosts, createPost, getPostCount } from "@/lib/posts"; import { cleanExpired } from "@/lib/recycle"; +import { CONTENT_DIR, BLOG_ROOT } from "@/lib/config"; +import fs from "fs"; export async function GET(request: NextRequest) { try { + // Debug logging + console.log("[api/posts] BLOG_ROOT:", BLOG_ROOT); + console.log("[api/posts] CONTENT_DIR:", CONTENT_DIR); + console.log("[api/posts] cwd:", process.cwd()); + console.log("[api/posts] env BLOG_ROOT:", process.env.BLOG_ROOT); + console.log("[api/posts] CONTENT_DIR exists:", fs.existsSync(CONTENT_DIR)); + cleanExpired(); // housekeeping on each request const { searchParams } = request.nextUrl; @@ -15,8 +24,11 @@ export async function GET(request: NextRequest) { const result = listPosts({ search, page, perPage, includeDrafts }); const totalCount = getPostCount(); + console.log("[api/posts] result:", result.total, "posts"); + return NextResponse.json({ ...result, totalCount }); } catch (error: unknown) { + console.error("[api/posts] error:", error); return NextResponse.json( { error: error instanceof Error ? error.message : "Unknown error" }, { status: 500 }