From 08e9ebbbb400bef21ff45d793d7f661bb70047bc Mon Sep 17 00:00:00 2001 From: Joerg Date: Fri, 16 Jan 2026 14:28:21 +0100 Subject: [PATCH] feat: Make backend port configurable via PORT environment variable (defaults to 3001) This allows changing the port without editing code: --- ecosystem.config.js | 4 ++-- src/backend/index.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ecosystem.config.js b/ecosystem.config.js index 1f8d0c0..dccdff0 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -7,7 +7,7 @@ module.exports = { cwd: '/path/to/award', env: { NODE_ENV: 'production', - PORT: 3001 + PORT: 4000 // Change this to your preferred port }, instances: 1, exec_mode: 'fork', @@ -19,4 +19,4 @@ module.exports = { log_date_format: 'YYYY-MM-DD HH:mm:ss Z' } ] -}; +}; \ No newline at end of file diff --git a/src/backend/index.js b/src/backend/index.js index b407f35..141c414 100644 --- a/src/backend/index.js +++ b/src/backend/index.js @@ -679,12 +679,13 @@ const app = new Elysia() } catch { return new Response('Frontend not built. Run `bun run build`', { status: 503 }); } - }) - - // Start server - .listen(3001); logger.info(`Backend server running`, { port: app.server?.port, url: `http://localhost:${app.server?.port}` }); logger.info(`API endpoints available`, { url: `http://localhost:${app.server?.port}/api` }); +// Start server - uses PORT environment variable if set, otherwise defaults to 3001 +const PORT = process.env.PORT || 3001; + +.listen(PORT); + export default app;