diff --git a/src/fetchWithAuth.js b/src/fetchWithAuth.js index 7df82ee..565a2c0 100644 --- a/src/fetchWithAuth.js +++ b/src/fetchWithAuth.js @@ -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 = {