From 13c1712695d2c00c8e136d9de4e82b2389d5d406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorem=20Ju=C3=A1rez?= Date: Tue, 21 Apr 2026 11:26:53 -0600 Subject: [PATCH] refactor: API_BASE always uses same-origin /api (nginx proxy handles routing) --- frontend/wonderloo.html | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/frontend/wonderloo.html b/frontend/wonderloo.html index ee7181b..6b62853 100644 --- a/frontend/wonderloo.html +++ b/frontend/wonderloo.html @@ -24,18 +24,11 @@ const COLORS = { // ═══════════════════════════════════════════════════════════ // API CONFIG -// En producción el HTML vive bajo el mismo host que /api. -// En dev (localhost o file://) apunta a http://localhost:3001. +// El HTML siempre se sirve detrás de nginx (local: localhost:8080, +// prod: dominio del cliente). nginx hace proxy_pass de /api/ al servicio +// api interno, por eso basta con el mismo origen. // ═══════════════════════════════════════════════════════════ -const API_BASE = (() => { - if (window.location.protocol === "file:" || window.location.origin.includes("localhost")) { - return "http://localhost:3001/api"; - } - return `${window.location.origin}/api`; -})(); - -// Debug — útil para validar que el origin/protocol se resuelven como esperamos -console.log("[wonderloo] origin:", window.location.origin, "protocol:", window.location.protocol, "API_BASE:", API_BASE); +const API_BASE = `${window.location.origin}/api`; async function apiFetch(path, options = {}) { const url = `${API_BASE}${path}`;