Files
jam-session-web/src/app/api/config/route.ts
T
2025-01-12 22:25:24 +01:00

17 lines
516 B
TypeScript

import {NextResponse} from "next/server";
import fs from "fs";
import path from "path";
export async function GET() {
const configPath = process.env.CONFIG_PATH || "./config.json";
const absolutePath = path.resolve(configPath);
if (!fs.existsSync(absolutePath)) {
return NextResponse.json({error: "Config file not found"}, {status: 404});
}
const fileContent = fs.readFileSync(absolutePath, "utf-8");
const config = JSON.parse(fileContent);
return NextResponse.json(config);
}