import "../../../../base64-CmWvODNW.mjs";
import "../../../../types-CuW0zWDA.mjs";
import { n as apiSuccess, r as handleError } from "../../../../error-CkAseSqZ.mjs";
import { t as isSafeRedirect } from "../../../../redirect-CoW3G-0U.mjs";

//#region src/astro/routes/api/auth/logout.ts
const prerender = false;
const POST = async ({ session, url }) => {
	try {
		if (session) session.destroy();
		const redirect = url.searchParams.get("redirect");
		if (isSafeRedirect(redirect)) return new Response(null, {
			status: 302,
			headers: { Location: redirect }
		});
		return apiSuccess({
			success: true,
			message: "Logged out successfully"
		});
	} catch (error) {
		return handleError(error, "Logout failed", "LOGOUT_ERROR");
	}
};

//#endregion
export { POST, prerender };
//# sourceMappingURL=logout.mjs.map