mirror of
https://github.com/PeterMaquiran/tvone.git
synced 2026-04-22 20:15:51 +00:00
20 lines
488 B
TypeScript
20 lines
488 B
TypeScript
import { env } from "@/lib/env";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export async function POST(req: Request) {
|
|
const { token } = await req.json();
|
|
const isHttps = new URL(req.url).protocol === "https:";
|
|
|
|
|
|
const res = NextResponse.json({ ok: true });
|
|
|
|
res.cookies.set("auth_token", token, {
|
|
httpOnly: true,
|
|
secure: true,
|
|
sameSite: isHttps ? "none" : "lax",
|
|
...(env.COOKIE_DOMAIN ? { domain: env.COOKIE_DOMAIN } : {}),
|
|
path: "/",
|
|
});
|
|
|
|
return res;
|
|
} |