27 lines
621 B
TypeScript
27 lines
621 B
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
export async function POST() {
|
|
try {
|
|
const response = NextResponse.json({
|
|
success: true,
|
|
message: 'Logout successful',
|
|
});
|
|
|
|
// Clear the auth token cookie
|
|
response.cookies.set('auth-token', '', {
|
|
httpOnly: true,
|
|
secure: process.env.NODE_ENV === 'production',
|
|
sameSite: 'strict',
|
|
maxAge: 0,
|
|
path: '/',
|
|
});
|
|
|
|
return response;
|
|
} catch (error) {
|
|
console.error('Logout error:', error);
|
|
return NextResponse.json(
|
|
{ success: false, error: 'Internal server error' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
} |