feat: implement dynamic API proxying to FastAPI backend

- Added a new route handler for dynamic API requests, allowing proxying to the FastAPI backend.
- Removed the previous rewrite configuration in next.config.ts for cleaner integration.
- Updated .env.example to clarify backend URL usage.
This commit is contained in:
Anish Sarkar 2026-04-22 05:44:03 +05:30
parent e86d279d55
commit 9ecccc5403
3 changed files with 65 additions and 16 deletions

View file

@ -44,21 +44,6 @@ const nextConfig: NextConfig = {
},
},
// Proxy /api/v1/* to the FastAPI backend. Keeps the real backend host
// out of the client bundle. FASTAPI_BACKEND_INTERNAL_URL is server-only.
async rewrites() {
const target =
process.env.FASTAPI_BACKEND_INTERNAL_URL ||
process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL ||
"http://localhost:8000";
return [
{
source: "/api/v1/:path*",
destination: `${target.replace(/\/+$/, "")}/api/v1/:path*`,
},
];
},
// Configure webpack (SVGR)
webpack: (config) => {
// SVGR: import *.svg as React components