Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 fix: Properly handle Token Expiry Defaults when Env Variable not set (#7834)

Samuel Path6488873bad51
diff --git a/api/server/services/AuthService.js b/api/server/services/AuthService.js
index 11b37ac886..2c285512ee 100644
--- a/api/server/services/AuthService.js
+++ b/api/server/services/AuthService.js
@@ -409,7 +409,9 @@ const setOpenIDAuthTokens = (tokenset, res) => {
return;
}
const { REFRESH_TOKEN_EXPIRY } = process.env ?? {};
- const expiryInMilliseconds = eval(REFRESH_TOKEN_EXPIRY) ?? 1000 * 60 * 60 * 24 * 7; // 7 days default
+ const expiryInMilliseconds = REFRESH_TOKEN_EXPIRY
+ ? eval(REFRESH_TOKEN_EXPIRY)
+ : 1000 * 60 * 60 * 24 * 7; // 7 days default
const expirationDate = new Date(Date.now() + expiryInMilliseconds);
if (tokenset == null) {
logger.error('[setOpenIDAuthTokens] No tokenset found in request');
diff --git a/packages/data-schemas/src/methods/session.ts b/packages/data-schemas/src/methods/session.ts
index 8c44aa54db..c5af51e932 100644
--- a/packages/data-schemas/src/methods/session.ts
+++ b/packages/data-schemas/src/methods/session.ts
@@ -13,7 +13,9 @@ export class SessionError extends Error {
}
const { REFRESH_TOKEN_EXPIRY } = process.env ?? {};
-const expires = eval(REFRESH_TOKEN_EXPIRY ?? '0') ?? 1000 * 60 * 60 * 24 * 7; // 7 days default
+const expires = REFRESH_TOKEN_EXPIRY
+ ? eval(REFRESH_TOKEN_EXPIRY)
+ : 1000 * 60 * 60 * 24 * 7; // 7 days default
// Factory function that takes mongoose instance and returns the methods
export function createSessionMethods(mongoose: typeof import('mongoose')) {