Add src/app/api/auth/verify-session/route.ts

This commit is contained in:
2026-03-11 20:10:38 +00:00
parent d4b97ada6d
commit 21fca3fecd

View File

@@ -0,0 +1,36 @@
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
try {
const authHeader = request.headers.get("authorization");
if (!authHeader || !authHeader.startsWith("Bearer ")) {
return NextResponse.json(
{ message: "Token não fornecido" },
{ status: 401 }
);
}
const token = authHeader.substring(7);
// Validate token (in production, verify JWT signature)
if (token.length !== 64) {
return NextResponse.json(
{ message: "Token inválido" },
{ status: 401 }
);
}
return NextResponse.json(
{
valid: true,
message: "Sessão válida"},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{ message: "Erro ao verificar sessão" },
{ status: 500 }
);
}
}