diff --git a/web/.env.example b/web/.env.example index 51631c2437..7923053f2c 100644 --- a/web/.env.example +++ b/web/.env.example @@ -56,3 +56,5 @@ NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER=true NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL=true NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL=true +# development api service base +NEXT_DEV_API_PROXY_BASE_URL=http://127.0.0.1:5001 diff --git a/web/next.config.js b/web/next.config.js index 9ce1b35644..07860e9b52 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -63,6 +63,23 @@ const nextConfig = { }, ] }, + async rewrites() { + // development service rewrite + if (process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production' && process.env.NEXT_DEV_API_PROXY_BASE_URL) { + const apiBase = process.env.NEXT_DEV_API_PROXY_BASE_URL + return [ + { + source: '/api/:path*', // match /api/* + destination: `${apiBase}/api/:path*`, // rewrite + }, + { + source: '/console/api/:path*', // match /console/api/* + destination: `${apiBase}/console/api/:path*`, // rewrite + }, + ] + } + return [] + }, output: 'standalone', }