fix(routing): move www redirect from vercel.json to Next.js config
Root cause: The redirect rule in /vercel.json was intercepting ALL requests (including /api/*) before they reached the Next.js app, causing API routes to timeout without generating any logs. Changes: - Move www → non-www redirect to apps/web/next.config.ts async redirects() - Remove redirects array from root vercel.json - Keep cron job configuration in root vercel.json Why this fixes the issue: - Next.js handles redirects AFTER route resolution (pages vs API routes) - API routes execute before redirect logic is applied - Redirects still work for pages as expected - More idiomatic for Next.js applications Testing: - API routes should now respond: /api/health, /api/tools - www.tpmjs.com should still redirect to tpmjs.com - All existing functionality preserved 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cc6c8243ed
commit
9be3af7427
2 changed files with 15 additions and 13 deletions
|
|
@ -3,6 +3,21 @@ import type { NextConfig } from 'next';
|
|||
const nextConfig: NextConfig = {
|
||||
transpilePackages: ['@tpmjs/ui', '@tpmjs/utils', '@tpmjs/db', '@tpmjs/types', '@tpmjs/env'],
|
||||
reactStrictMode: true,
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
source: '/:path*',
|
||||
has: [
|
||||
{
|
||||
type: 'host',
|
||||
value: 'www.tpmjs.com',
|
||||
},
|
||||
],
|
||||
destination: 'https://tpmjs.com/:path*',
|
||||
permanent: true,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
13
vercel.json
13
vercel.json
|
|
@ -9,19 +9,6 @@
|
|||
"silent": false,
|
||||
"autoJobCancelation": true
|
||||
},
|
||||
"redirects": [
|
||||
{
|
||||
"source": "/:path*",
|
||||
"has": [
|
||||
{
|
||||
"type": "host",
|
||||
"value": "www.tpmjs.com"
|
||||
}
|
||||
],
|
||||
"destination": "https://tpmjs.com/:path*",
|
||||
"permanent": true
|
||||
}
|
||||
],
|
||||
"crons": [
|
||||
{
|
||||
"path": "/api/sync/changes",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue