From 91999e7691354fc8fb09e5007a74dbf20a1af06b Mon Sep 17 00:00:00 2001 From: Mireya Cueto Garrido Date: Tue, 2 Jun 2026 10:09:27 +0200 Subject: [PATCH] Update runtime ports and deployment defaults. Switch backend/frontend to ports 8074/8075 and align Docker, CORS, frontend API base URL, and docs so deployment uses the new endpoints consistently. --- GUIA_API_Y_FLUJO.md | 12 ++++++------ README.md | 2 +- backend/.env.example | 2 +- backend/Dockerfile | 4 ++-- backend/app/core/config.py | 2 +- docker-compose.yml | 10 +++++----- frontend/.env.example | 2 +- frontend/Dockerfile | 2 +- frontend/README.md | 8 ++++---- frontend/src/api/client.js | 2 +- frontend/vite.config.js | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/GUIA_API_Y_FLUJO.md b/GUIA_API_Y_FLUJO.md index ccbae35..3444973 100644 --- a/GUIA_API_Y_FLUJO.md +++ b/GUIA_API_Y_FLUJO.md @@ -2,7 +2,7 @@ Documento resumen para entender **qué hace el usuario en cada paso**, **qué endpoint usar**, **cabeceras**, **cuerpos**, **ejemplos de respuesta** y **errores típicos**. -**Base URL de ejemplo:** `http://localhost:8000` +**Base URL de ejemplo:** `http://localhost:8074` --- @@ -131,7 +131,7 @@ Detalle de cuerpos, respuestas y errores: **sección 4** de esta guía. **Ejemplo:** ```bash -curl -s http://localhost:8000/health +curl -s http://localhost:8074/health ``` **Respuesta OK (200):** @@ -165,7 +165,7 @@ curl -s http://localhost:8000/health **Ejemplo:** ```bash -curl -s -X POST http://localhost:8000/auth/register \ +curl -s -X POST http://localhost:8074/auth/register \ -H "Content-Type: application/json" \ -d '{"email":"profesor@ejemplo.com","password":"ClaveSegura1","full_name":"María"}' ``` @@ -303,7 +303,7 @@ Todas requieren: `Authorization: Bearer ` **Ejemplo mínimo:** ```bash -curl -s -X POST http://localhost:8000/exam/templates \ +curl -s -X POST http://localhost:8074/exam/templates \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ @@ -415,7 +415,7 @@ Sirven para **texto** que la IA puede usar al generar (PDF, DOCX, TXT, MD; imág **Ejemplo:** ```bash -curl -s -X POST "http://localhost:8000/exam/templates/TEMPLATE_UUID/materials" \ +curl -s -X POST "http://localhost:8074/exam/templates/TEMPLATE_UUID/materials" \ -H "Authorization: Bearer $TOKEN" \ -F "file=@./apuntes.pdf" ``` @@ -468,7 +468,7 @@ Solo para **mostrar en la pregunta** (Moodle); no rellenan el contexto de texto **Ejemplo:** ```bash -curl -s -X POST "http://localhost:8000/exam/templates/TEMPLATE_UUID/images" \ +curl -s -X POST "http://localhost:8074/exam/templates/TEMPLATE_UUID/images" \ -H "Authorization: Bearer $TOKEN" \ -F "file=@./diagrama.png" \ -F "caption=Diagrama del modelo ER" diff --git a/README.md b/README.md index 9bfc74d..5c38df6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ docker compose up --build La API queda disponible en: ```text -http://localhost:8000 +http://localhost:8074 ``` ## Configuración diff --git a/backend/.env.example b/backend/.env.example index 6625d88..af09411 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -9,7 +9,7 @@ API_KEY=change-me-in-production-min-16-chars DATABASE_URL=postgresql+psycopg://genexamenes:genexamenes@db:5432/genexamenes # --- CORS (orígenes del frontend, separados por coma) --- -ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000 +ALLOWED_ORIGINS=http://localhost:8075 # --- Rate limiting y tamaño de petición --- RATE_LIMIT_REQUESTS=60 diff --git a/backend/Dockerfile b/backend/Dockerfile index 7d5524f..73ce560 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -23,6 +23,6 @@ RUN mkdir -p /app/uploads && chown -R app:app /app/uploads USER app -EXPOSE 8000 +EXPOSE 8074 -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8074"] diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 8e60ac1..4d5f827 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -10,7 +10,7 @@ class Settings(BaseSettings): api_prefix: str = "" api_key: str = Field(min_length=16) database_url: str = "postgresql+psycopg://genexamenes:genexamenes@localhost:5432/genexamenes" - allowed_origins: str = "http://localhost:5173,http://localhost:3000" + allowed_origins: str = "http://localhost:8075" rate_limit_requests: int = Field(default=60, ge=1) rate_limit_window_seconds: int = Field(default=60, ge=1) max_request_bytes: int = Field(default=1_048_576, ge=1_024) diff --git a/docker-compose.yml b/docker-compose.yml index d7751a4..8aada33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,13 +6,13 @@ services: - ./backend/.env environment: DATABASE_URL: postgresql+psycopg://genexamenes:genexamenes@db:5432/genexamenes - # Sobrescribe backend/.env si aún tiene el puerto 3000 del frontend antiguo. - ALLOWED_ORIGINS: http://localhost:5173,http://localhost:3000 + # Sobrescribe backend/.env con el puerto actual del frontend. + ALLOWED_ORIGINS: http://localhost:8075 LLM_BASE_URL: LLM_MODEL: qwen3.5:35b LLM_TIMEOUT_SECONDS: "180" ports: - - "8000:8000" + - "8074:8074" depends_on: db: condition: service_healthy @@ -24,10 +24,10 @@ services: build: context: ./frontend args: - VITE_API_URL: ${VITE_API_URL:-http://localhost:8000} + VITE_API_URL: ${VITE_API_URL:-http://localhost:8074} VITE_GOOGLE_CLIENT_ID: ${VITE_GOOGLE_CLIENT_ID:-} ports: - - "5173:80" + - "8075:80" depends_on: - backend restart: unless-stopped diff --git a/frontend/.env.example b/frontend/.env.example index d293dcc..952b12d 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -1,5 +1,5 @@ # URL base del backend (accesible desde el navegador) -VITE_API_URL=http://localhost:8000 +VITE_API_URL=http://localhost:8074 # (Opcional) Client ID de Google para "Iniciar sesión con Google". # Debe coincidir con GOOGLE_CLIENT_ID del backend. diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 8479044..9664897 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -2,7 +2,7 @@ FROM node:20-alpine AS build WORKDIR /app -ARG VITE_API_URL=http://localhost:8000 +ARG VITE_API_URL=http://localhost:8074 ARG VITE_GOOGLE_CLIENT_ID= ENV VITE_API_URL=$VITE_API_URL ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID diff --git a/frontend/README.md b/frontend/README.md index 3e04f27..fdcc233 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -25,20 +25,20 @@ src/ ## Desarrollo local -Requisitos: Node 20+ y el backend corriendo en `http://localhost:8000`. +Requisitos: Node 20+ y el backend corriendo en `http://localhost:8074`. ```bash cd frontend cp .env.example .env # ajusta VITE_API_URL si es necesario npm install -npm run dev # http://localhost:5173 +npm run dev # http://localhost:8075 ``` ## Variables de entorno | Variable | Descripción | | ----------------------- | -------------------------------------------------------- | -| `VITE_API_URL` | URL base del backend (por defecto `http://localhost:8000`). | +| `VITE_API_URL` | URL base del backend (por defecto `http://localhost:8074`). | | `VITE_GOOGLE_CLIENT_ID` | (Opcional) Client ID de Google. Si está vacío, se oculta el botón de Google. | > Las variables `VITE_*` se incrustan en el build, por lo que apuntan al backend @@ -54,7 +54,7 @@ npm run preview # sirve el build localmente ## Docker El `docker-compose.yml` de la raíz construye el frontend con un build multi-stage -(Node → Nginx) y lo publica en `http://localhost:5173`: +(Node → Nginx) y lo publica en `http://localhost:8075`: ```bash docker compose up --build diff --git a/frontend/src/api/client.js b/frontend/src/api/client.js index d1481a7..e4ec5ec 100644 --- a/frontend/src/api/client.js +++ b/frontend/src/api/client.js @@ -1,7 +1,7 @@ import axios from "axios"; export const API_URL = - import.meta.env.VITE_API_URL?.replace(/\/$/, "") || "http://localhost:8000"; + import.meta.env.VITE_API_URL?.replace(/\/$/, "") || "http://localhost:8074"; const TOKEN_KEY = "genex_token"; diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 77a11e3..6ee4104 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -5,6 +5,6 @@ export default defineConfig({ plugins: [react()], server: { host: true, - port: 5173, + port: 8075, }, });