diff --git a/surfsense_web/components/chat/ChatInterface.tsx b/surfsense_web/components/chat/ChatInterface.tsx index 377d141b4..2d5830fd7 100644 --- a/surfsense_web/components/chat/ChatInterface.tsx +++ b/surfsense_web/components/chat/ChatInterface.tsx @@ -43,6 +43,12 @@ export default function ChatInterface({ searchMode, onSearchModeChange, }: ChatInterfaceProps) { + const [token, setToken] = useState(null); + useEffect(() => { + const bearerToken = localStorage.getItem("surfsense_bearer_token"); + setToken(bearerToken); + }, []); + const { chat_id, search_space_id } = useParams(); const [chatDetails, setChatDetails] = useState(null); const [isChatPannelOpen, setIsChatPannelOpen] = useState(false); @@ -59,7 +65,7 @@ export default function ChatInterface({ const { getPodcastByChatId } = usePodcast(); const { fetchChatDetails } = useChatAPI({ - token: localStorage.getItem("surfsense_bearer_token"), + token, search_space_id: search_space_id as string, });