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:
parent
bba35f1b2c
commit
907b5ee3bf
@ -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();
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user