Skip to content

Commit bb1db21

Browse files
authored
fix: Alllow port to be set via env instead hardcoded (#869)
Prefer env port instead hardcoded Signed-off-by: Rafael Raposo <[email protected]>
1 parent f80d817 commit bb1db21

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

website/console/env/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ if (file.error) {
2121
/** Current environment environment. "development", "test" or "production" */
2222
const NODE_ENV = process.env.NODE_ENV || 'development';
2323

24+
/** Port to run the server on */
25+
const PORT = process.env.PORT || 8080;
26+
2427
/**
2528
* Certificate path required for local development, should not include trailing '/'.
2629
* Located at top level of the repository in script folder
@@ -76,6 +79,7 @@ const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || '';
7679

7780
const processEnv = {
7881
NODE_ENV,
82+
PORT,
7983
ADMIN_API,
8084
ADMIN_API_URL,
8185
BASE_URL,
@@ -86,6 +90,7 @@ const processEnv = {
8690

8791
export {
8892
NODE_ENV,
93+
PORT,
8994
BASE_URL,
9095
BASE_HREF,
9196
DISABLE_CONSOLE_ROUTE_PREFIX,

website/console/src/server/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const fs = require('fs');
1515
// const https = require('https');
1616
const env = require('../../env');
1717

18-
const PORT = 8080;
19-
2018
collectDefaultMetrics();
2119

2220
const app = express();
@@ -56,7 +54,7 @@ app.use(mainRouter);
5654

5755
const showEntryPointUrl = () => {
5856
console.log(chalk.magenta(`Express server ready!`));
59-
const url = `https://${env.LOCAL_DEV_HOST}:${PORT}${env.BASE_URL}`;
57+
const url = `https://${env.LOCAL_DEV_HOST}:${env.PORT}${env.BASE_URL}`;
6058

6159
// Open a new browser tab if in development
6260
if (env.NODE_ENV === 'development') {
@@ -84,9 +82,9 @@ if (env.ADMIN_API_USE_SSL === 'https') {
8482
},
8583
app,
8684
)
87-
.listen(PORT, showEntryPointUrl);
85+
.listen(env.PORT, showEntryPointUrl);
8886
} else {
89-
server = app.listen(PORT, showEntryPointUrl);
87+
server = app.listen(env.PORT, showEntryPointUrl);
9088
}
9189

9290
const shutdown: NodeJS.SignalsListener = (signal) => {

0 commit comments

Comments
 (0)