fix(mining-admin-web): prevent duplicate /api/v2 in rewrite destination
Clean NEXT_PUBLIC_API_URL to remove trailing /api/v2 if present, preventing paths like /api/v2/api/v2/configs/mining/status Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c9690b0d36
commit
467d637ccc
|
|
@ -3,10 +3,15 @@ const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
|
// NEXT_PUBLIC_API_URL 应该是后端服务的基础 URL,如 http://mining-admin-service:3023
|
||||||
|
// 前端请求 /api/xxx 会被转发到 {API_URL}/api/v2/xxx
|
||||||
|
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3023';
|
||||||
|
// 移除末尾可能存在的 /api/v2 避免重复
|
||||||
|
const cleanUrl = apiBaseUrl.replace(/\/api\/v2\/?$/, '');
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: '/api/:path*',
|
source: '/api/:path*',
|
||||||
destination: `${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3023'}/api/v2/:path*`,
|
destination: `${cleanUrl}/api/v2/:path*`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue