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;