2026-04-21 20:51:23 +01:00
|
|
|
import { env } from "@/lib/env";
|
2026-04-18 23:45:46 +01:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
|
|
|
|
|
export async function POST(req: Request) {
|
|
|
|
|
const { token } = await req.json();
|
2026-04-21 21:05:12 +01:00
|
|
|
const isHttps = new URL(req.url).protocol === "https:";
|
|
|
|
|
|
2026-04-18 23:45:46 +01:00
|
|
|
|
|
|
|
|
const res = NextResponse.json({ ok: true });
|
|
|
|
|
|
|
|
|
|
res.cookies.set("auth_token", token, {
|
|
|
|
|
httpOnly: true,
|
|
|
|
|
secure: true,
|
2026-04-21 21:05:12 +01:00
|
|
|
sameSite: isHttps ? "none" : "lax",
|
2026-04-21 20:51:23 +01:00
|
|
|
...(env.COOKIE_DOMAIN ? { domain: env.COOKIE_DOMAIN } : {}),
|
2026-04-18 23:45:46 +01:00
|
|
|
path: "/",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|