From 417f290056e731ebed6d0f1aa03075a73e5dc808 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 28 Apr 2026 10:31:37 +0200 Subject: [PATCH] chore: enhance environment configuration for frontend and Google authentication - Add VITE_API_URL to docker-compose for frontend service. - Introduce FRONTEND_URL in backend environment files for redirection after Google login. - Update Google authentication router to use dynamic FRONTEND_URL for redirects. --- backend/.env.example | 6 ++++++ backend/api/routers/google_auth.py | 3 ++- docker-compose.yaml | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/.env.example b/backend/.env.example index 1f82712..ec7a048 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -19,3 +19,9 @@ GOOGLE_REDIRECT_URI=http://localhost:8070/api/auth/google/callback # Clave para firmar los JWT (usa algo largo y aleatorio en producción) SECRET_KEY=cambia-esta-clave-en-produccion + +# URL del frontend a la que se redirige tras el login con Google +# Con docker-compose en local: http://localhost:8071 +# Con Vite directo en local: http://localhost:5173 +# En producción: https://tu-dominio.com +FRONTEND_URL=http://localhost:5173 diff --git a/backend/api/routers/google_auth.py b/backend/api/routers/google_auth.py index 2769868..1c787b8 100644 --- a/backend/api/routers/google_auth.py +++ b/backend/api/routers/google_auth.py @@ -13,6 +13,7 @@ GOOGLE_CLIENT_ID = os.getenv("GOOGLE_CLIENT_ID") GOOGLE_CLIENT_SECRET = os.getenv("GOOGLE_CLIENT_SECRET") REDIRECT_URI = os.getenv("GOOGLE_REDIRECT_URI") SECRET_KEY = os.getenv("SECRET_KEY") +FRONTEND_URL = os.getenv("FRONTEND_URL", "http://localhost:5173") @router.get("/login") async def google_login(): @@ -97,4 +98,4 @@ async def google_callback(request: Request): {"$set": {"token": token}} ) - return RedirectResponse(f"http://localhost:5173/login?token={token}") \ No newline at end of file + return RedirectResponse(f"{FRONTEND_URL}/login?token={token}") \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 4885b65..48211f1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -21,6 +21,8 @@ services: volumes: - ./frontend:/app - /app/node_modules + environment: + - VITE_API_URL=http://localhost:8070/api depends_on: - backend