20 lines
644 B
TypeScript
20 lines
644 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { readFile } from "node:fs/promises";
|
|
import { safeJoinSitePath } from "@/lib/config";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function GET(
|
|
_req: Request,
|
|
ctx: { params: Promise<{ dir: string }> }
|
|
) {
|
|
try {
|
|
const { dir } = await ctx.params;
|
|
const filePath = safeJoinSitePath(dir, "log", "access.log");
|
|
const content = await readFile(filePath, { encoding: "utf-8" });
|
|
return new NextResponse(content, { headers: { "content-type": "text/plain; charset=utf-8" } });
|
|
} catch (error) {
|
|
return NextResponse.json({ error: String(error) }, { status: 404 });
|
|
}
|
|
}
|