All checks were successful
Deploy Web Client / deploy (push) Successful in 12s
- Remove middleware (no SSR auth check) - AuthGuard component checks localStorage token - Protected route group (protected) wraps all pages - Login page is public - All API calls use Authorization: Bearer header
21 lines
652 B
TypeScript
21 lines
652 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { createToken } from "@/lib/auth";
|
|
|
|
const AUTH_USER = process.env.AUTH_USER || "admin";
|
|
const AUTH_PASS = process.env.AUTH_PASS || "teamboard";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const { username, password } = await req.json();
|
|
|
|
if (username === AUTH_USER && password === AUTH_PASS) {
|
|
const token = await createToken({
|
|
sub: username,
|
|
name: username,
|
|
provider: "local",
|
|
});
|
|
return NextResponse.json({ token, user: { name: username, provider: "local" } });
|
|
}
|
|
|
|
return NextResponse.json({ error: "Invalid credentials" }, { status: 401 });
|
|
}
|