This commit is contained in:
2025-08-15 13:45:12 -06:00
parent 7296c4dcf0
commit 5fec43781c

View File

@@ -91,10 +91,12 @@ export const fetchWithAuth = async (url, options = {}) => {
let token = localStorage.getItem('access');
// Configurar headers por defecto
const defaultHeaders = {
'Content-Type': 'application/json',
...(token && { 'Authorization': `Bearer ${token}` })
};
let defaultHeaders = {};
if (token) defaultHeaders['Authorization'] = `Bearer ${token}`;
// Solo poner Content-Type si no es GET o si hay body
if ((options.method && options.method.toUpperCase() !== 'GET') || options.body) {
defaultHeaders['Content-Type'] = 'application/json';
}
// Combinar headers
const finalOptions = {