fix: rewrite /api/* to internal backend (localhost:3001), not public URL
The previous rewrite used NEXT_PUBLIC_API_URL (https://coop.hobokenchicken.com) as the destination. This created a loop through Caddy: /api/* → Next.js → rewrite to public URL → Caddy → Next.js → 502. Now routes /api/* and /webhooks/* directly to the Express backend on localhost:3001, bypassing Caddy entirely for API calls.
This commit is contained in:
@@ -3,15 +3,14 @@ const nextConfig = {
|
|||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
allowedDevOrigins: ['172.20.1.238'],
|
allowedDevOrigins: ['172.20.1.238'],
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: '/api/:path*',
|
source: '/api/:path*',
|
||||||
destination: `${apiUrl}/api/:path*`,
|
destination: 'http://localhost:3001/api/:path*',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: '/webhooks/:path*',
|
source: '/webhooks/:path*',
|
||||||
destination: `${apiUrl}/webhooks/:path*`,
|
destination: 'http://localhost:3001/webhooks/:path*',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user