From de85e82554f4963c5143723c4490a7b057d50a9e Mon Sep 17 00:00:00 2001 From: Nurfog Date: Fri, 27 Mar 2026 12:17:33 -0300 Subject: [PATCH] fix: Configure correct API URLs without ports in .env - Add NEXT_PUBLIC_CMS_API_URL and NEXT_PUBLIC_LMS_API_URL to .env - URLs use domains without ports (nginx proxy handles routing) - Add validation to detect URLs with ports that cause CORS errors - Show warnings if URLs have incorrect port configuration - Verify environment variables in both .env and containers Co-authored-by: Qwen-Coder --- deploy.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/deploy.sh b/deploy.sh index fb1b5f6..3a507a7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -398,6 +398,27 @@ else echo " Usando PRODUCTION - certificados reales" fi fi + +# Configurar URLs de la API para el frontend +echo " Configurando URLs de la API para el frontend..." +if [ "$PROTOCOL" = "https" ]; then + CMS_URL="https://studio.norteamericano.com" + LMS_URL="https://learning.norteamericano.com" +else + CMS_URL="http://studio.norteamericano.com" + LMS_URL="http://learning.norteamericano.com" +fi + +# Remover valores existentes +sed -i "/^NEXT_PUBLIC_CMS_API_URL=/d" .env 2>/dev/null || true +sed -i "/^NEXT_PUBLIC_LMS_API_URL=/d" .env 2>/dev/null || true + +# Agregar URLs correctas (sin puertos - nginx proxy maneja el routing) +echo "NEXT_PUBLIC_CMS_API_URL=$CMS_URL" >> .env +echo "NEXT_PUBLIC_LMS_API_URL=$LMS_URL" >> .env +echo " URLs configuradas:" +echo " CMS: $CMS_URL" +echo " LMS: $LMS_URL" echo "" REMOTE_SCRIPT_CONTENT @@ -604,6 +625,13 @@ sleep 15 echo "" echo "Verificando variables de entorno en los contenedores..." echo "" + +# Verificar .env +echo "Variables en .env:" +grep "NEXT_PUBLIC_" .env 2>/dev/null || echo " No se encontraron variables NEXT_PUBLIC" +echo "" + +# Verificar en los contenedores echo "Studio:" $DOCKER_CMD exec openccb-studio env | grep NEXT_PUBLIC || echo " No se pudo verificar" echo "" @@ -611,6 +639,26 @@ echo "Experience:" $DOCKER_CMD exec openccb-experience env | grep NEXT_PUBLIC || echo " No se pudo verificar" echo "" +# Verificar que las URLs no tengan puertos +echo "Verificando que las URLs no tengan puertos..." +CMS_ENV=$(grep "NEXT_PUBLIC_CMS_API_URL" .env 2>/dev/null | cut -d"=" -f2) +LMS_ENV=$(grep "NEXT_PUBLIC_LMS_API_URL" .env 2>/dev/null | cut -d"=" -f2) + +if echo "$CMS_ENV" | grep -q ":[0-9]"; then + echo " ⚠️ ADVERTENCIA: CMS_API_URL tiene puerto ($CMS_ENV)" + echo " Esto causará errores CORS. Debe ser solo el dominio." +else + echo " ✅ CMS_API_URL correcta: $CMS_ENV" +fi + +if echo "$LMS_ENV" | grep -q ":[0-9]"; then + echo " ⚠️ ADVERTENCIA: LMS_API_URL tiene puerto ($LMS_ENV)" + echo " Esto causará errores CORS. Debe ser solo el dominio." +else + echo " ✅ LMS_API_URL correcta: $LMS_ENV" +fi +echo "" + # ======================================== # VERIFICAR ESTADO # ========================================