@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
34 lines (29 loc) • 933 B
text/typescript
import NextAuth from 'next-auth';
import { getServerDBConfig } from '@/config/db';
import { serverDB } from '@/database/server';
import { LobeNextAuthDbAdapter } from './adapter';
import config from './auth.config';
const { NEXT_PUBLIC_ENABLED_SERVER_SERVICE } = getServerDBConfig();
/**
* NextAuth initialization with Database adapter
*
* @example
* ```ts
* import NextAuthNode from '@/libs/next-auth';
* const { handlers } = NextAuthNode;
* ```
*
* @note
* If you meet the edge runtime compatible problem,
* you can import from `@/libs/next-auth/edge` which is not initial with the database adapter.
*
* The difference and usage of the two different NextAuth modules is can be
* ref to: https://github.com/lobehub/lobe-chat/pull/2935
*/
export default NextAuth({
...config,
adapter: NEXT_PUBLIC_ENABLED_SERVER_SERVICE ? LobeNextAuthDbAdapter(serverDB) : undefined,
session: {
strategy: 'jwt',
},
});