From 72614e0844f6b6d56e6b69e3e316a7827c786a8b Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Thu, 30 Apr 2026 15:51:25 -0400 Subject: [PATCH] fix: rewrite /api/* to internal backend (localhost:3001), not public URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/next.config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/next.config.js b/frontend/next.config.js index 4a576d5..28a3320 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -3,15 +3,14 @@ const nextConfig = { output: 'standalone', allowedDevOrigins: ['172.20.1.238'], async rewrites() { - const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001'; return [ { source: '/api/:path*', - destination: `${apiUrl}/api/:path*`, + destination: 'http://localhost:3001/api/:path*', }, { source: '/webhooks/:path*', - destination: `${apiUrl}/webhooks/:path*`, + destination: 'http://localhost:3001/webhooks/:path*', }, ]; },