From c779301f2ff722c2a50dfa53e2c39df36e53679e Mon Sep 17 00:00:00 2001 From: Dan Livings Date: Tue, 8 Oct 2024 13:56:53 +0100 Subject: [PATCH] Allow for active port to be configured through `PORT` env var Heroku uses dynamic port assignment, so this allows Heroku to connect to the application using the port it's assigned. The default port of 3000 is still available for local development. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 2312a57..6f2aba0 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const httpServer = createServer(async (request, response) => { return response.end(template); }); -const PORT = 3000; +const PORT = process.env.PORT || 3000; httpServer.listen(PORT, () => { console.info(`Server is running on port ${PORT}`); });