Semodifico fetch with auth

This commit is contained in:
2025-08-15 13:40:49 -06:00
parent e86547d10d
commit 80acbeb023
2 changed files with 6 additions and 8 deletions

4
.env
View File

@@ -1,4 +1,4 @@
VITE_DEBUG_MODE=false VITE_DEBUG_MODE=false
VITE_EFC_API_URL=https://api.efc-aduanasoft.com/api/v1 VITE_EFC_API_URL=http://192.168.1.195:8000/api/v1
VITE_EFC_MICROSERVICE_URL=https://api.efc-aduanasoft.com/microservicio/api/v1 VITE_EFC_MICROSERVICE_URL=http://192.168.1.195:8001/api/v1

View File

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