fix(redirects): exclude API routes from www redirect

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 <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-11-28 20:28:59 +10:00
parent 9be3af7427
commit c42bfb684c

View file

@ -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,
},
];