Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alllow port to be set via env instead hardcoded #869

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions website/console/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ if (file.error) {
/** Current environment environment. "development", "test" or "production" */
const NODE_ENV = process.env.NODE_ENV || 'development';

/** Port to run the server on */
const PORT = process.env.PORT || 8080;

/**
* Certificate path required for local development, should not include trailing '/'.
* Located at top level of the repository in script folder
Expand Down Expand Up @@ -76,6 +79,7 @@ const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || '';

const processEnv = {
NODE_ENV,
PORT,
ADMIN_API,
ADMIN_API_URL,
BASE_URL,
Expand All @@ -86,6 +90,7 @@ const processEnv = {

export {
NODE_ENV,
PORT,
BASE_URL,
BASE_HREF,
DISABLE_CONSOLE_ROUTE_PREFIX,
Expand Down
8 changes: 3 additions & 5 deletions website/console/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const fs = require('fs');
// const https = require('https');
const env = require('../../env');

const PORT = 8080;

collectDefaultMetrics();

const app = express();
Expand Down Expand Up @@ -56,7 +54,7 @@ app.use(mainRouter);

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

// Open a new browser tab if in development
if (env.NODE_ENV === 'development') {
Expand Down Expand Up @@ -84,9 +82,9 @@ if (env.ADMIN_API_USE_SSL === 'https') {
},
app,
)
.listen(PORT, showEntryPointUrl);
.listen(env.PORT, showEntryPointUrl);
} else {
server = app.listen(PORT, showEntryPointUrl);
server = app.listen(env.PORT, showEntryPointUrl);
}

const shutdown: NodeJS.SignalsListener = (signal) => {
Expand Down
Loading