Skip to content

Commit

Permalink
enhance(server): introduce SERVER_HOST variable (#11394)
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner authored Oct 10, 2024
1 parent 0b3caee commit 70001af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/envvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ Flaw types to be fixed when running `fix-flaws`.

## Server

### `SERVER_HOST`

**Default: (undefined)**

Set this to `0.0.0.0` to access the server from a different local device.

### `SERVER_PORT`

**Default: `5042`**
Expand Down
5 changes: 3 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,10 @@ console.log(
: ""
);

const HOST = process.env.SERVER_HOST || undefined;
const PORT = parseInt(process.env.SERVER_PORT || "5042");
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
app.listen(PORT, HOST, () => {
console.log(`Listening on ${HOST ? `${HOST}:` : "port "}${PORT}`);
if (process.env.EDITOR) {
console.log(`Your EDITOR is set to: ${chalk.bold(process.env.EDITOR)}`);
} else {
Expand Down
5 changes: 4 additions & 1 deletion server/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,8 @@ app.get("/*", async (req, res) => {
.sendFile(path.join(STATIC_ROOT, "en-us", "_spas", "404.html"));
});

const HOST = process.env.SERVER_HOST || undefined;
const PORT = parseInt(process.env.SERVER_PORT || "5042");
app.listen(PORT, () => console.log(`Listening on port ${PORT}`));
app.listen(PORT, HOST, () =>
console.log(`Listening on ${HOST ? `${HOST}:` : "port "}${PORT}`)
);

0 comments on commit 70001af

Please sign in to comment.