From 80acbeb0239f51575b6d5e55cbb9c05efdff1384 Mon Sep 17 00:00:00 2001 From: Kevin Rosales Date: Fri, 15 Aug 2025 13:40:49 -0600 Subject: [PATCH] Semodifico fetch with auth --- .env | 4 ++-- src/fetchWithAuth.js | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 4694ca2..bae8a6f 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ VITE_DEBUG_MODE=false -VITE_EFC_API_URL=https://api.efc-aduanasoft.com/api/v1 -VITE_EFC_MICROSERVICE_URL=https://api.efc-aduanasoft.com/microservicio/api/v1 +VITE_EFC_API_URL=http://192.168.1.195:8000/api/v1 +VITE_EFC_MICROSERVICE_URL=http://192.168.1.195:8001/api/v1 diff --git a/src/fetchWithAuth.js b/src/fetchWithAuth.js index 565a2c0..7df82ee 100644 --- a/src/fetchWithAuth.js +++ b/src/fetchWithAuth.js @@ -91,12 +91,10 @@ export const fetchWithAuth = async (url, options = {}) => { let token = localStorage.getItem('access'); // Configurar headers por defecto - 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'; - } + const defaultHeaders = { + 'Content-Type': 'application/json', + ...(token && { 'Authorization': `Bearer ${token}` }) + }; // Combinar headers const finalOptions = {