Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

build: try adding a . in front of the domain for the cookie domain

Brad Barbin7cb723e3e97b
diff --git a/apps/carbon/app/services/session.server.ts b/apps/carbon/app/services/session.server.ts
index 6241b71eab..ee2d71c7b4 100644
--- a/apps/carbon/app/services/session.server.ts
+++ b/apps/carbon/app/services/session.server.ts
@@ -8,6 +8,7 @@ import {
SESSION_KEY,
SESSION_MAX_AGE,
SESSION_SECRET,
+ VERCEL_URL,
} from "~/config/env";
import { redis } from "@carbon/redis";
@@ -32,6 +33,15 @@ async function assertAuthSession(
return authSession;
}
+// Function to extract domain from URL
+function removeSubdomain(url: string): string {
+ const parts = url.split("/")[0].split(".");
+
+ const domain = parts.slice(-2).join(".");
+
+ return domain;
+}
+
const sessionStorage = createCookieSessionStorage({
cookie: {
name: "carbon",
@@ -40,6 +50,8 @@ const sessionStorage = createCookieSessionStorage({
sameSite: "lax",
secrets: [SESSION_SECRET],
secure: NODE_ENV === "production",
+ domain:
+ NODE_ENV === "production" ? `.${removeSubdomain(VERCEL_URL)}` : undefined,
},
});