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'); let token = localStorage.getItem('access');
// Configurar headers por defecto // Configurar headers por defecto
const defaultHeaders = { let defaultHeaders = {};
'Content-Type': 'application/json', if (token) defaultHeaders['Authorization'] = `Bearer ${token}`;
...(token && { '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 // Combinar headers
const finalOptions = { const finalOptions = {