From 450a8a5daa31b2ada7282031df19474c3764ddfc Mon Sep 17 00:00:00 2001 From: ypratama Date: Tue, 1 Sep 2026 11:27:59 +0700 Subject: [PATCH] Fix: Bind backend to 0.0.0.0 in Docker to fix healthcheck failures and frontend proxy connection refused errors --- backend/server.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/server.js b/backend/server.js index ff0c4f0..e633437 100644 --- a/backend/server.js +++ b/backend/server.js @@ -152,12 +152,11 @@ app.use((err, req, res, next) => { }); // ─── Start Server ───────────────────────────────────────────────────────────── -// Bind to 127.0.0.1 in production to prevent direct external access to port 3001. -// All external traffic must go through the reverse proxy (Apache/Nginx) at port 80/443. -const BIND_HOST = process.env.NODE_ENV === 'production' ? '127.0.0.1' : '0.0.0.0'; +// Use BIND_HOST from environment or default to 0.0.0.0 for Docker compatibility +const BIND_HOST = process.env.BIND_HOST || '0.0.0.0'; app.listen(PORT, BIND_HOST, () => { console.log(`\n🚀 BackOne API Server berjalan di http://${BIND_HOST}:${PORT}`); console.log(`🔌 API Health : http://${BIND_HOST}:${PORT}/api/health`); console.log(`📡 Mode : READ-ONLY dari MongoDB (data dikirim oleh Proxy Server)`); - console.log(`🔒 Security : Bound to ${BIND_HOST} (internal only in production)\n`); + console.log(`🔒 Security : Bound to ${BIND_HOST}\n`); });