Fix code review issues: remove /api route, add missing routes, fix localhost fallback

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-08 23:43:39 +00:00
parent 4c03f69f43
commit cdbb39513f
3 changed files with 16 additions and 8 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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`,
},
];
},
}