From cdbb39513fb750e1b2032c4ee6efcffd8e129fe9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 23:43:39 +0000 Subject: [PATCH] Fix code review issues: remove /api route, add missing routes, fix localhost fallback Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- README.md | 4 ++-- docs/CAPROVER.md | 2 +- frontend/next.config.js | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f0ebba2..ff79a5b 100644 --- a/README.md +++ b/README.md @@ -141,11 +141,11 @@ Images are automatically built and pushed to GitHub Container Registry (GHCR) on ### API Access -**Docker Compose**: Backend is on `http://localhost:5000`, frontend proxies API requests automatically. +**Docker Compose**: Backend is on `http://localhost:5000`, frontend on `http://localhost:3000` proxies API requests automatically. **Production Deployments**: Two options: 1. **Separate domains**: Set `NEXT_PUBLIC_API_URL` to backend URL (e.g., `https://api.example.com`) -2. **Single domain with proxy**: Set `NEXT_PUBLIC_API_URL=""` and `BACKEND_URL` to internal backend address. Access all routes through the frontend domain (e.g., `https://repo.example.com/auth/login`) +2. **Single domain with proxy**: Set `NEXT_PUBLIC_API_URL=""` and `BACKEND_URL` to internal backend address. The frontend proxies `/auth/*`, `/v1/*`, `/admin/*`, `/health`, and `/schema` routes to the backend. Access all routes through the frontend domain (e.g., `https://repo.example.com/auth/login`) ## Schema Configuration diff --git a/docs/CAPROVER.md b/docs/CAPROVER.md index 0efce62..fc72321 100644 --- a/docs/CAPROVER.md +++ b/docs/CAPROVER.md @@ -155,7 +155,7 @@ You should see a response about missing credentials (this is expected). NODE_ENV=production PORT=3000 ``` - This option allows the frontend to proxy `/auth/*`, `/api/*`, and `/v1/*` requests to the backend internally. + This option allows the frontend to proxy `/auth/*`, `/v1/*`, `/admin/*`, `/health`, and `/schema` requests to the backend internally. With this setup, users access everything through the frontend domain (e.g., `https://repo.wardcrew.com/auth/login`). **Important**: Replace `goodrepo-backend` with your actual backend app name in CapRover. diff --git a/frontend/next.config.js b/frontend/next.config.js index ae148b8..524f72c 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -3,13 +3,9 @@ const nextConfig = { output: 'standalone', async rewrites() { // Get backend URL from environment, fallback to localhost for development - const backendUrl = process.env.BACKEND_URL || 'http://backend:5000'; + const backendUrl = process.env.BACKEND_URL || 'http://localhost:5000'; return [ - { - source: '/api/:path*', - destination: `${backendUrl}/:path*`, - }, { source: '/auth/:path*', destination: `${backendUrl}/auth/:path*`, @@ -18,6 +14,18 @@ const nextConfig = { source: '/v1/:path*', destination: `${backendUrl}/v1/:path*`, }, + { + source: '/admin/:path*', + destination: `${backendUrl}/admin/:path*`, + }, + { + source: '/health', + destination: `${backendUrl}/health`, + }, + { + source: '/schema', + destination: `${backendUrl}/schema`, + }, ]; }, }