Files
portaldata/app/api/auth/logout/route.ts
Randa Firman Putra e028039ee2 First commit
2025-06-18 22:03:32 +07:00

29 lines
653 B
TypeScript

import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
export async function POST() {
try {
const response = NextResponse.json(
{ message: 'Logout berhasil' },
{ status: 200 }
);
// Clear the token cookie with additional security options
response.cookies.set('token', '', {
expires: new Date(0),
path: '/',
httpOnly: true,
secure: false,
sameSite: 'lax'
});
return response;
} catch (error) {
console.error('Logout error:', error);
return NextResponse.json(
{ error: 'Terjadi kesalahan saat logout' },
{ status: 500 }
);
}
}