From 9aadf3835ee57cae046d4ba0d28d4b2bdaafc684 Mon Sep 17 00:00:00 2001 From: Camila Huamani Date: Sun, 23 Nov 2025 23:22:43 -0500 Subject: [PATCH 1/2] chore: configure Firebase Hosting --- .env.development | 20 ++++++++++++++++++ .env.production | 20 ++++++++++++++++++ .firebaserc | 5 +++++ .github/workflows/firebase-hosting-merge.yml | 20 ++++++++++++++++++ .../firebase-hosting-pull-request.yml | 21 +++++++++++++++++++ firebase.json | 16 ++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 .env.development create mode 100644 .env.production create mode 100644 .firebaserc create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml create mode 100644 firebase.json diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..cb842a8 --- /dev/null +++ b/.env.development @@ -0,0 +1,20 @@ +# Google Maps Configuration +VITE_GOOGLE_MAPS_API_KEY=AIzaSyDWlqL8kfdt5AwSYU1tXzPJM3NTXTkEuUM + +# API Configuration +VITE_API_BASE_URL=http://localhost:3000 +VITE_API_TIMEOUT=30000 + +# API Endpoints +VITE_USER_ENDPOINT_PATH=/users +VITE_PORTS_ENDPOINT_PATH=/api/v1/ports +VITE_PORT_CONNECTIONS_ENDPOINT_PATH=/api/v1/port-connections +VITE_ROUTES_ENDPOINT_PATH=/api/v1/routes +VITE_EXPORTS_ENDPOINT_PATH=/exports +VITE_ALGORITHMS_ENDPOINT_PATH=/algorithms +VITE_OPTIMIZATION_ENDPOINT_PATH=/api/v1/routes/compute + +# Application Settings +VITE_APP_NAME=BerrySend +VITE_APP_VERSION=1.0.0 + diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..f2c9af8 --- /dev/null +++ b/.env.production @@ -0,0 +1,20 @@ +# Google Maps Configuration +VITE_GOOGLE_MAPS_API_KEY=AIzaSyDWlqL8kfdt5AwSYU1tXzPJM3NTXTkEuUM + +# API Configuration (update with production URL) +VITE_API_BASE_URL=https://api.berrysend.com +VITE_API_TIMEOUT=30000 + +# API Endpoints +VITE_USER_ENDPOINT_PATH=/users +VITE_PORTS_ENDPOINT_PATH=/api/v1/ports +VITE_PORT_CONNECTIONS_ENDPOINT_PATH=/api/v1/port-connections +VITE_ROUTES_ENDPOINT_PATH=/api/v1/routes +VITE_EXPORTS_ENDPOINT_PATH=/exports +VITE_ALGORITHMS_ENDPOINT_PATH=/algorithms +VITE_OPTIMIZATION_ENDPOINT_PATH=/api/v1/routes/compute + +# Application Settings +VITE_APP_NAME=BerrySend +VITE_APP_VERSION=1.0.0 + diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..9986aaa --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "berrysend-app" + } +} diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..418fbcc --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - develop +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BERRYSEND_APP }} + channelId: live + projectId: berrysend-app diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..64161f6 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,21 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BERRYSEND_APP }} + projectId: berrysend-app diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..2c33c29 --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} From b6b99709027c28a54e75927d2e59f631a61fb71e Mon Sep 17 00:00:00 2001 From: Camila Huamani Date: Sun, 23 Nov 2025 23:26:29 -0500 Subject: [PATCH 2/2] chore: configure Firebase Hosting --- .env.development | 2 +- .firebase/hosting.ZGlzdA.cache | 14 ++++ API_URL_CHANGE.md | 135 +++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 .firebase/hosting.ZGlzdA.cache create mode 100644 API_URL_CHANGE.md diff --git a/.env.development b/.env.development index cb842a8..fa882ca 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ VITE_GOOGLE_MAPS_API_KEY=AIzaSyDWlqL8kfdt5AwSYU1tXzPJM3NTXTkEuUM # API Configuration -VITE_API_BASE_URL=http://localhost:3000 +VITE_API_BASE_URL=https://fake-api-4n0p.onrender.com VITE_API_TIMEOUT=30000 # API Endpoints diff --git a/.firebase/hosting.ZGlzdA.cache b/.firebase/hosting.ZGlzdA.cache new file mode 100644 index 0000000..6c97d73 --- /dev/null +++ b/.firebase/hosting.ZGlzdA.cache @@ -0,0 +1,14 @@ +index.html,1763958181407,0e3f1452c1209fb8c1e90faf9b6c3709bccffa623982d6eed47cb347f582eb3c +assets/visualization-page-qcryGJmo.css,1763958181406,8ff4683adad504937d2350f56ba3ee0fd52f06fce090c1aad940ed8b9be81066 +assets/port-page-CQhjS9DO.css,1763958181406,d39e26e9bc98df07137800aaa3000a3ad1e9ca3d2ac0e283d18b5ec572088a26 +assets/port-page.component-C6ddnWAC.js,1763958181407,f3cc824aba69a9e17b72cc535858c4be6c3ae99b01611e74e1ca35f169044a7d +assets/optimization-page-JblpntI1.css,1763958181406,7fa970e03835678644d840c533c2476557319dcf24101fd8cd4e419af2660006 +favicon.ico,1762229037809,3d3d5c038cc96d71c43ffff92b9bf099f92adf9d867d0849ddcc2086c63c907b +assets/visualization-page.component-CmK1zWoj.js,1763958181407,1de1713c5b41f0a3c03da0d33a79200a33e2fd900f5eea0242c9736b9bdd37b4 +assets/optimization-page.component-DUNAYf-F.js,1763958181407,af16d65b8cf07c78709d8c71d1d35b923d8850bd6b5b79c29b83909505fc21e1 +assets/register-page.component-CcraQaLq.js,1763958181407,a728313ff3c4c5766db0d0361d7a32b97258bc27db5c77f5b4ca1284eb0eecdb +assets/login-page.component-B0bs8AnG.js,1763958181407,5e41d404955dfdf2ae1bcfb59baab7845cef75a36d20ca64c0b6711f16410837 +assets/auth-layout-BLnr3ucQ.css,1763958181406,eafccf5f100313bdc38848105396d8df3ad29e2c7f33dba30a0576005c84ebdc +assets/auth-layout.component-DMnwoECF.js,1763958181407,228ffdff2cf00305fec3db564da9671a3c6d1492b0a2fca8baefc8152aff6f93 +assets/index-C4Hm7WUM.css,1763958181406,a31df13b16f6b10cf19ad35c87f145ce0d560b230248af3c30ae76fa02aef28f +assets/index-DApqfwZF.js,1763958181407,30e74153ac3146b4256b7b2b86a0328423f74d29ac4cc77c110cd1b9502b384d diff --git a/API_URL_CHANGE.md b/API_URL_CHANGE.md new file mode 100644 index 0000000..d3b6b4c --- /dev/null +++ b/API_URL_CHANGE.md @@ -0,0 +1,135 @@ +# ✅ Cambio de API Completado + +## 🔄 Lo Que Se Cambió + +Se ha actualizado la URL de la API de `localhost:3000` a la API en la nube: + +``` +❌ ANTES: http://localhost:3000 +✅ AHORA: https://fake-api-4n0p.onrender.com +``` + +## 📝 Archivos Actualizados + +### `.env.development` +```env +# Antes +VITE_API_BASE_URL=http://localhost:3000 + +# Ahora +VITE_API_BASE_URL=https://fake-api-4n0p.onrender.com +``` + +## 🚀 Próximos Pasos + +### 1. Reinicia el servidor +```bash +npm run dev +``` + +### 2. Verifica la conexión +- Abre la consola (F12) +- Ejecuta: +```javascript +quickConfigCheck() +``` + +**Deberías ver:** +``` +🔧 BerrySend Config Check +API: https://fake-api-4n0p.onrender.com +Ports: https://fake-api-4n0p.onrender.com/api/v1/ports +Exports: https://fake-api-4n0p.onrender.com/exports +✅ Config OK +``` + +## ⚙️ Cómo Funciona + +El sistema ahora usa esta estructura: + +``` +1. Tu navegador + ↓ +2. Aplicación BerrySend (http://localhost:5173) + ↓ +3. API en la nube (https://fake-api-4n0p.onrender.com) + ↓ +4. Base de datos +``` + +## 🔐 Cambios en Diferentes Ambientes + +### Desarrollo (Development) +```env +VITE_API_BASE_URL=https://fake-api-4n0p.onrender.com +``` + +### Producción (Production) - OPCIONAL +Si necesitas cambiar también la producción, edita `.env.production` + +## ✨ Ventajas + +✅ **API en la nube** - No necesitas servidor local +✅ **Mismo endpoint** para todos +✅ **Escalable** - La API puede crecer sin afectar tu código +✅ **HTTPS** - Conexión segura + +## 🔍 Verificación + +Después de reiniciar el servidor, verifica: + +1. **Conectividad**: Los datos deben cargar sin errores +2. **Consola**: No debe haber errores de CORS o conexión +3. **Funcionalidad**: Todas las páginas deben funcionar normalmente + +## 📊 Endpoints Disponibles + +Tu aplicación usará estos endpoints: + +``` +✅ https://fake-api-4n0p.onrender.com/api/v1/ports +✅ https://fake-api-4n0p.onrender.com/api/v1/port-connections +✅ https://fake-api-4n0p.onrender.com/exports +✅ https://fake-api-4n0p.onrender.com/algorithms +✅ https://fake-api-4n0p.onrender.com/api/v1/routes/compute +``` + +## ⚡ Cambios Rápidos + +### Si necesitas volver a localhost +```env +VITE_API_BASE_URL=http://localhost:3000 +``` + +### Si necesitas otra URL +```env +VITE_API_BASE_URL=https://tu-api-url.com +``` + +Solo edita `.env.development` y reinicia el servidor. + +## 📞 Troubleshooting + +### Problema: CORS Error +**Solución:** La API en la nube debe permitir CORS desde tu dominio + +### Problema: Timeout +**Solución:** Aumenta el timeout en `.env.development`: +```env +VITE_API_TIMEOUT=60000 +``` + +### Problema: Datos no cargan +**Solución:** Verifica que la URL sea correcta: +```javascript +// En consola +import.meta.env.VITE_API_BASE_URL +// Debe mostrar: https://fake-api-4n0p.onrender.com +``` + +--- + +**Estado:** ✅ COMPLETADO +**Fecha:** 23 de Noviembre, 2025 +**API:** https://fake-api-4n0p.onrender.com +