fix(room): fix file upload missing /api prefix and credentials

Upload URL was missing /api prefix causing 404, and missing
credentials: 'include' for cookie-based authentication.
This commit is contained in:
ZhenYi 2026-04-29 09:40:58 +08:00
parent bba35f1b2c
commit 907b5ee3bf

View File

@ -166,7 +166,7 @@ export const MessageInput = forwardRef<MessageInputHandle, MessageInputProps>(fu
const formData = new FormData();
formData.append('file', file);
const baseUrl = import.meta.env.VITE_API_BASE_URL ?? window.location.origin;
const res = await fetch(`${baseUrl}/rooms/${activeRoomId}/upload`, {method: 'POST', body: formData});
const res = await fetch(`${baseUrl}/api/rooms/${activeRoomId}/upload`, {method: 'POST', body: formData, credentials: 'include'});
if (!res.ok) throw new Error('Upload failed');
return res.json();
};