api9nin / src /app /api /shutdown /route.js
github-actions[bot]
deploy from github actions 2026-06-18
c8ae75d
Raw
History Blame Contribute Delete
693 Bytes
import { NextResponse } from "next/server";
import { headers } from "next/headers";
export async function POST() {
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 });
}
const response = NextResponse.json({ success: true, message: "Shutting down..." });
setTimeout(() => {
process.exit(0);
}, 500);
return response;
}