@lobehub/lobehub 2.0.0-next.126 → 2.0.0-next.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.127](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.126...v2.0.0-next.127)
6
+
7
+ <sup>Released on **2025-11-27**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Better-auth fallback next-auth providers env.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Better-auth fallback next-auth providers env, closes [#10459](https://github.com/lobehub/lobe-chat/issues/10459) ([e167075](https://github.com/lobehub/lobe-chat/commit/e167075))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ## [Version 2.0.0-next.126](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.125...v2.0.0-next.126)
6
31
 
7
32
  <sup>Released on **2025-11-27**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Better-auth fallback next-auth providers env."
6
+ ]
7
+ },
8
+ "date": "2025-11-27",
9
+ "version": "2.0.0-next.127"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "fixes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.126",
3
+ "version": "2.0.0-next.127",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,60 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
+
3
+ import { getAuthConfig } from './auth';
4
+
5
+ const ORIGINAL_ENV = { ...process.env };
6
+ const ORIGINAL_WINDOW = globalThis.window;
7
+
8
+ describe('getAuthConfig fallbacks', () => {
9
+ beforeEach(() => {
10
+ // reset env to a clean clone before each test
11
+ process.env = { ...ORIGINAL_ENV };
12
+ globalThis.window = ORIGINAL_WINDOW;
13
+ });
14
+
15
+ afterEach(() => {
16
+ process.env = { ...ORIGINAL_ENV };
17
+ globalThis.window = ORIGINAL_WINDOW;
18
+ });
19
+
20
+ it('should fall back to NEXT_AUTH_SSO_PROVIDERS when AUTH_SSO_PROVIDERS is empty string', () => {
21
+ process.env.AUTH_SSO_PROVIDERS = '';
22
+ process.env.NEXT_AUTH_SSO_PROVIDERS = 'logto,github';
23
+
24
+ // Simulate server runtime so @t3-oss/env treats this as server-side access
25
+ // (happy-dom sets window by default in Vitest)
26
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
+ // @ts-expect-error - allow overriding for test
28
+ globalThis.window = undefined;
29
+
30
+ const config = getAuthConfig();
31
+
32
+ expect(config.AUTH_SSO_PROVIDERS).toBe('logto,github');
33
+ });
34
+
35
+ it('should fall back to NEXT_AUTH_SECRET when AUTH_SECRET is empty string', () => {
36
+ process.env.AUTH_SECRET = '';
37
+ process.env.NEXT_AUTH_SECRET = 'nextauth-secret';
38
+
39
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
+ // @ts-expect-error - allow overriding for test
41
+ globalThis.window = undefined;
42
+
43
+ const config = getAuthConfig();
44
+
45
+ expect(config.AUTH_SECRET).toBe('nextauth-secret');
46
+ });
47
+
48
+ it('should fall back to NEXTAUTH_URL origin when NEXT_PUBLIC_AUTH_URL is empty string', () => {
49
+ process.env.NEXT_PUBLIC_AUTH_URL = '';
50
+ process.env.NEXTAUTH_URL = 'https://example.com/api/auth';
51
+
52
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
53
+ // @ts-expect-error - allow overriding for test
54
+ globalThis.window = undefined;
55
+
56
+ const config = getAuthConfig();
57
+
58
+ expect(config.NEXT_PUBLIC_AUTH_URL).toBe('https://example.com');
59
+ });
60
+ });
package/src/envs/auth.ts CHANGED
@@ -237,14 +237,14 @@ export const getAuthConfig = () => {
237
237
  NEXT_PUBLIC_ENABLE_BETTER_AUTH: process.env.NEXT_PUBLIC_ENABLE_BETTER_AUTH === '1',
238
238
  // Fallback to NEXTAUTH_URL origin for seamless migration from next-auth
239
239
  NEXT_PUBLIC_AUTH_URL:
240
- process.env.NEXT_PUBLIC_AUTH_URL ??
240
+ process.env.NEXT_PUBLIC_AUTH_URL ||
241
241
  (process.env.NEXTAUTH_URL ? new URL(process.env.NEXTAUTH_URL).origin : undefined),
242
242
  NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION: process.env.NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION === '1',
243
243
  NEXT_PUBLIC_ENABLE_MAGIC_LINK: process.env.NEXT_PUBLIC_ENABLE_MAGIC_LINK === '1',
244
244
  // Fallback to NEXT_AUTH_SECRET for seamless migration from next-auth
245
- AUTH_SECRET: process.env.AUTH_SECRET ?? process.env.NEXT_AUTH_SECRET,
245
+ AUTH_SECRET: process.env.AUTH_SECRET || process.env.NEXT_AUTH_SECRET,
246
246
  // Fallback to NEXT_AUTH_SSO_PROVIDERS for seamless migration from next-auth
247
- AUTH_SSO_PROVIDERS: process.env.AUTH_SSO_PROVIDERS ?? process.env.NEXT_AUTH_SSO_PROVIDERS,
247
+ AUTH_SSO_PROVIDERS: process.env.AUTH_SSO_PROVIDERS || process.env.NEXT_AUTH_SSO_PROVIDERS,
248
248
 
249
249
  // better-auth env for Cognito provider is different from next-auth's one
250
250
  AUTH_COGNITO_DOMAIN: process.env.AUTH_COGNITO_DOMAIN,