import { NextResponse } from "next/server";
export async function POST(request: Request) {
const { password } = await request.json();
// Replace with your secure password check.
if (password === process.env.PASSWORD) {
const response = NextResponse.json({ success: true });
// Set a cookie called "authenticated". In production, you may
// want to sign or encrypt cookies.
response.cookies.set("authenticated", "true", {
httpOnly: true,
path: "/",
maxAge: 5 * 60 * 24, // 24 hours
});
return response;
}
return NextResponse.json({ success: false }, { status: 401 });
}
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const { password } = await request.json();
// Replace with your secure password check.
if (password === process.env.PASSWORD) {
const response = NextResponse.json({ success: true });
// Set a cookie called "authenticated". In production, you may
// want to sign or encrypt cookies.
response.cookies.set("authenticated", "true", {
httpOnly: true,
path: "/",
maxAge: 5 * 60 * 24, // 24 hours
});
return response;
}
return NextResponse.json({ success: false }, { status: 401 });
}