/home/techb158/balavpn.abdallabala.com/src/app/api/auth/logout
Edit: /home/techb158/balavpn.abdallabala.com/src/app/api/auth/logout/route.js (713B)
const { logout } = require("../../../../services/auth-service");
const { errorResponse } = require("../../../../lib/http");
export async function POST(request) {
try {
const cookie = request.headers.get("cookie") || "";
const match = cookie.match(/cosmic_session=([^;]+)/);
if (match) await logout(match[1]);
return new Response(JSON.stringify({ ok: true }), {
status: 200,
headers: {
"Content-Type": "application/json",
"Set-Cookie": `cosmic_session=; HttpOnly; ${process.env.NODE_ENV === 'production' ? 'Secure; ' : ''}SameSite=Lax; Path=/; Max-Age=0`,
"Cache-Control": "no-store"
}
});
} catch (error) {
return errorResponse(error);
}
}