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.

refactor: improve cookie options handling in setTheme function (#647)

Naveen Kashyapd68f8aa0e157
diff --git a/apps/erp/app/services/theme.server.ts b/apps/erp/app/services/theme.server.ts
index ea662d4c73..eb40d61c56 100644
--- a/apps/erp/app/services/theme.server.ts
+++ b/apps/erp/app/services/theme.server.ts
@@ -22,9 +22,13 @@ export function getTheme(request: Request): Theme {
}
export function setTheme(theme: string) {
- return cookie.serialize(cookieName, theme, {
+ const cookieOptions: cookie.SerializeOptions = {
path: "/",
- maxAge: 31536000,
- domain: DOMAIN
- });
+ maxAge: 31536000
+ };
+
+ if (DOMAIN && !DOMAIN.startsWith("localhost")) {
+ cookieOptions.domain = DOMAIN;
+ }
+ return cookie.serialize(cookieName, theme, cookieOptions);
}