gendesign/tradein-mvp/frontend/next.config.ts
lekss361 5082f50d53 fix(tradein): убрать basePath redirect-loop
Под basePath=/trade-in next.config redirects() + app/page.tsx с
redirect(/trade-in) делали /trade-in/ → /trade-in/trade-in (двойной
префикс basePath) → пустая страница / 404.

- Перенёс контент app/trade-in/page.tsx → app/page.tsx (теперь корень
  Next = /trade-in/ snaружи)
- Удалил app/trade-in/ как избыточный
- Удалил redirects() блок из next.config.ts
- router.replace("/?id=...") вместо "/trade-in?id=..." — basePath
  префиксит автоматически
2026-05-21 01:05:49 +03:00

30 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { NextConfig } from "next";
// basePath: пусто в dev / `/trade-in` в production когда сидим под gendsgn.ru/trade-in.
// Прокидывается через env при сборке Docker.
const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
const nextConfig: NextConfig = {
reactStrictMode: true,
output: "standalone",
// basePath сдвигает ВСЕ routes на /trade-in/* — Next сам префиксит ассеты
// и navigation. Пустая строка = no-op.
basePath: BASE_PATH || undefined,
// assetPrefix — для CDN (мы не используем, оставляем пустым)
// trailingSlash — false (default), важно чтобы Caddy /trade-in без слэша
// редиректил на /trade-in/.
// В dev (без Caddy) Next.js сам проксирует /api/* и /health на backend
// так что браузер использует относительные same-origin URLs.
async rewrites() {
const backend = process.env.BACKEND_URL ?? "http://localhost:8000";
return [
{ source: "/api/:path*", destination: `${backend}/api/:path*` },
{ source: "/health", destination: `${backend}/health` },
];
},
};
export default nextConfig;