fix: allow dashboard refresh cookie on http deployments (#5026)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user