From 613a913a3dfe640bfaffb2c73928554c132eb03c Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Tue, 9 Dec 2025 08:29:31 +0100 Subject: [PATCH] Add Next.js API rewrite proxy - Added rewrites() in next.config.js to proxy /api/v1/* to backend - Works regardless of whether Nginx is in front or external proxy goes directly to Next.js - Disabled standalone output for non-Docker deployments --- frontend/next.config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/next.config.js b/frontend/next.config.js index 149fa60..5f11810 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -1,7 +1,21 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - output: 'standalone', // Required for Docker deployment + // output: 'standalone', // Only needed for Docker deployment + + // Proxy API requests to backend + // This ensures /api/v1/* works regardless of how the server is accessed + async rewrites() { + // Determine backend URL based on environment + const backendUrl = process.env.BACKEND_URL || 'http://127.0.0.1:8000' + + return [ + { + source: '/api/v1/:path*', + destination: `${backendUrl}/api/v1/:path*`, + }, + ] + }, } module.exports = nextConfig