mirror of
https://github.com/johndoe6345789/goodpackagerepo.git
synced 2026-04-24 13:54:59 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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`,
|
||||
},
|
||||
];
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user