From c42bfb684c63c7e2cb15bc40fe61c4e255af7845 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Fri, 28 Nov 2025 20:28:59 +1000 Subject: [PATCH] fix(redirects): exclude API routes from www redirect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The redirect was being applied to ALL routes including API routes, causing them to return "Redirecting..." instead of executing. Use negative lookahead regex `/((?!api).*)` to exclude /api/* paths from the www → non-www redirect. This ensures: - API routes execute normally without redirection - Page routes still redirect from www.tpmjs.com to tpmjs.com - Follows Option 2 from the investigation plan 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/web/next.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 4672ead..805bbbe 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -6,14 +6,14 @@ const nextConfig: NextConfig = { async redirects() { return [ { - source: '/:path*', + source: '/((?!api).*)', has: [ { type: 'host', value: 'www.tpmjs.com', }, ], - destination: 'https://tpmjs.com/:path*', + destination: 'https://tpmjs.com/$1', permanent: true, }, ];