diff --git a/app/api/conversations/route.ts b/app/api/conversations/route.ts index 0dd3fe3..642da1b 100644 --- a/app/api/conversations/route.ts +++ b/app/api/conversations/route.ts @@ -1,5 +1,3 @@ -export const dynamic = 'force-dynamic' - import { type NextRequest } from 'next/server' import { NextResponse } from 'next/server' import { client, getInfo, setSession } from '@/app/api/utils/common' @@ -11,7 +9,11 @@ export async function GET(request: NextRequest) { return NextResponse.json(data, { headers: setSession(sessionId), }) - } catch (error) { - return NextResponse.json([]); + } + catch (error: any) { + return NextResponse.json({ + data: [], + error: error.message, + }) } } diff --git a/app/components/index.tsx b/app/components/index.tsx index ba6d3bc..b2b5334 100644 --- a/app/components/index.tsx +++ b/app/components/index.tsx @@ -223,7 +223,12 @@ const Main: FC = () => { const [conversationData, appParams] = await Promise.all([fetchConversations(), fetchAppParams()]) // handle current conversation id - const { data: conversations } = conversationData as { data: ConversationItem[] } + const { data: conversations, error } = conversationData as { data: ConversationItem[]; error: string } + if (error) { + Toast.notify({ type: 'error', message: error }) + throw new Error(error) + return + } const _conversationId = getConversationIdFromStorage(APP_ID) const isNotNewConversation = conversations.some(item => item.id === _conversationId)