mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-13 13:16:21 +00:00
add period to cookie
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { ResponseT } from "@server/types/Response";
|
||||
import { pullEnv } from "@app/lib/pullEnv";
|
||||
|
||||
type CookieOptions = {
|
||||
path?: string;
|
||||
@@ -10,6 +11,7 @@ type CookieOptions = {
|
||||
sameSite?: "lax" | "strict" | "none";
|
||||
expires?: Date;
|
||||
maxAge?: number;
|
||||
domain?: string;
|
||||
};
|
||||
|
||||
function parseSetCookieString(setCookie: string): {
|
||||
@@ -22,6 +24,8 @@ function parseSetCookieString(setCookie: string): {
|
||||
const [name, ...valParts] = nameValue.split("=");
|
||||
const value = valParts.join("="); // handles '=' inside JWT
|
||||
|
||||
const env = pullEnv();
|
||||
|
||||
const options: CookieOptions = {};
|
||||
|
||||
for (const attr of attrParts) {
|
||||
@@ -46,6 +50,18 @@ function parseSetCookieString(setCookie: string): {
|
||||
case "max-age":
|
||||
options.maxAge = parseInt(v, 10);
|
||||
break;
|
||||
case "domain":
|
||||
options.domain = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.domain) {
|
||||
const d = env.app.dashboardUrl
|
||||
? "." + new URL(env.app.dashboardUrl).hostname
|
||||
: undefined;
|
||||
if (d) {
|
||||
options.domain = d;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user