// Simple /api/login route for password auth
import type { NextApiRequest, NextApiResponse } from "next";

const PASSWORD = process.env.SF_WEB_PASSWORD || "devpass";
const TOKEN = process.env.SF_WEB_AUTH_TOKEN || "dev-token";

export default function handler(req: NextApiRequest, res: NextApiResponse) {
	if (req.method !== "POST") return res.status(405).end();
	const { password } = req.body;
	if (password === PASSWORD) {
		res.status(200).json({ token: TOKEN });
	} else {
		res.status(401).json({ error: "Invalid password" });
	}
}
