From 8978cc2a611c39bb05f2b8fc5b8fd99f614d5c2d Mon Sep 17 00:00:00 2001 From: pollutri Date: Wed, 3 Jun 2026 10:27:45 +0200 Subject: [PATCH] Aggiornata la gestione dei basepath --- next.config.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/next.config.ts b/next.config.ts index f82232b..1c8caba 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,6 +5,26 @@ const nextConfig: NextConfig = { basePath: BASE_PATH || undefined, allowedDevOrigins: ['10.210.1.225'], serverExternalPackages: ['sanitize-html', 'file-type'], + // Quando l'app vive sotto un sotto-percorso, le rotte "nude" rispondevano 404: + // chi atterra su http://host:3000/ o /admin viene rediretto sotto il basePath. + // basePath: false evita che Next prefissi automaticamente source/destination. + async redirects() { + if (!BASE_PATH) return []; + return [ + { + source: '/', + destination: BASE_PATH, + basePath: false, + permanent: false, + }, + { + source: '/admin', + destination: `${BASE_PATH}/admin`, + basePath: false, + permanent: false, + }, + ]; + }, }; export default nextConfig;