2026-01-04 21:58:59 -05:00
|
|
|
import { NextResponse } from "next/server";
|
2026-04-08 04:39:09 -04:00
|
|
|
import { headers } from "next/headers";
|
2026-01-04 21:58:59 -05:00
|
|
|
|
|
|
|
|
export async function POST() {
|
2026-04-08 04:39:09 -04:00
|
|
|
if (process.env.NODE_ENV === "production") {
|
|
|
|
|
return NextResponse.json({ success: false, message: "Not allowed in production" }, { status: 403 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const secret = process.env.SHUTDOWN_SECRET;
|
|
|
|
|
const authorization = headers().get("authorization");
|
|
|
|
|
|
|
|
|
|
if (!secret || authorization !== `Bearer ${secret}`) {
|
|
|
|
|
return NextResponse.json({ success: false, message: "Unauthorized" }, { status: 401 });
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-04 21:58:59 -05:00
|
|
|
const response = NextResponse.json({ success: true, message: "Shutting down..." });
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|