Removed some of the calls to process.env; Used server props instead

This commit is contained in:
Andrew Pennington 2024-08-15 22:25:00 +01:00
parent 376220b26e
commit f51f36a411
No known key found for this signature in database
GPG key ID: E9DA097213FD17EA
5 changed files with 52 additions and 11 deletions

View file

@ -260,7 +260,7 @@ const loadMessages = async (
setIsMessagesLoaded(true);
};
const ChatWindow = ({ id }: { id?: string }) => {
const ChatWindow = ({ id, backendApiUrl }: { id?: string, backendApiUrl: string }) => {
const searchParams = useSearchParams();
const initialMessage = searchParams.get('q');
@ -434,7 +434,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
lastMsg.sources.length > 0 &&
!lastMsg.suggestions
) {
const suggestions = await getSuggestions(messagesRef.current);
const suggestions = await getSuggestions(messagesRef.current, backendApiUrl);
setMessages((prev) =>
prev.map((msg) => {
if (msg.messageId === lastMsg.messageId) {

View file

@ -9,10 +9,12 @@ const DeleteChat = ({
chatId,
chats,
setChats,
backendApiUrl
}: {
chatId: string;
chats: Chat[];
setChats: (chats: Chat[]) => void;
backendApiUrl: string
}) => {
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
const [loading, setLoading] = useState(false);
@ -21,7 +23,7 @@ const DeleteChat = ({
setLoading(true);
try {
const res = await fetch(
`${process.env.BACKEND_API_URL}/chats/${chatId}`,
`${backendApiUrl}/chats/${chatId}`,
{
method: 'DELETE',
headers: {