Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

fix: allow dashboard refresh cookie on http deployments (#5026)

Sense_wang7a5df64746e1
diff --git a/server/dashboard/src/app/api/auth/refresh/route.ts b/server/dashboard/src/app/api/auth/refresh/route.ts
index cc827c41a..0de4609d7 100644
--- a/server/dashboard/src/app/api/auth/refresh/route.ts
+++ b/server/dashboard/src/app/api/auth/refresh/route.ts
@@ -4,9 +4,23 @@ import { AUTH_ENDPOINTS } from "@/utils/api-endpoints";
import { getServerApiUrl } from "@/lib/server-api-url";
const COOKIE_NAME = "mem0_refresh_token";
+
+function shouldUseSecureCookie() {
+ const dashboardUrl = process.env.DASHBOARD_URL;
+ if (!dashboardUrl) {
+ return process.env.NODE_ENV === "production";
+ }
+
+ try {
+ return new URL(dashboardUrl).protocol === "https:";
+ } catch {
+ return process.env.NODE_ENV === "production";
+ }
+}
+
const COOKIE_OPTIONS = {
httpOnly: true,
- secure: process.env.NODE_ENV === "production",
+ secure: shouldUseSecureCookie(),
sameSite: "lax" as const,
path: "/",
maxAge: 30 * 24 * 60 * 60, // 30 days