Skip to content

Commit a259aee

Browse files
committed
allow to set the server hostname via environment variable HOST
1 parent 2e248d8 commit a259aee

5 files changed

Lines changed: 20 additions & 4 deletions

File tree

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ application, major version changes in Plotly.js will also trigger a major
1111
version change in this application.
1212

1313

14-
## Version 1.5.0-pre1 (2021-08-01)
14+
## Version 1.5.0 (2021-08-01)
1515

1616
* __[new feature]__
1717
The port to which the server binds can now be changed by setting the environment
1818
variable `PORT`. If `PORT` is not set or is not a valid port number, then the
1919
default port 3000 is used.
2020

21+
* __[new feature]__
22+
The hostname which the server shall use can now be changed by setting the
23+
environment variable `HOST`. If `HOST` is not set, then `localhost` will be
24+
used as default.
25+
2126
## Version 1.4.2 (2021-08-01)
2227

2328
* __[maintenance]__

export-server/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

export-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plotly-node-export-server",
3-
"version": "1.5.0-pre1",
3+
"version": "1.5.0",
44
"description": "Plotly.js Node.js export server",
55
"repository": {
66
"url": "https://gitlab.com/striezel/plotly-node-export-server.git",

export-server/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const phantomize = require('./phantomize.js');
2626
const url = require('url');
2727
const uuidv4 = require('uuid/v4');
2828

29-
const hostname = 'localhost';
29+
// Use hostname from environment variable HOST, if it is set.
30+
const hostname = process.env.HOST || 'localhost';
3031
// Use port from environment variable PORT, if it is set and valid.
3132
const parsedPort = parseInt(process.env.PORT);
3233
if (process.env.PORT) {

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ npm start
6969
In these cases the server will bind to port 4000 instead of the default port
7070
3000.
7171

72+
The hostname can be changed, too, by setting the `HOST` environment variable in
73+
the same manner, e. g.:
74+
75+
``` bash
76+
export HOST=0.0.0.0
77+
npm start
78+
```
79+
80+
If `HOST` is not set, then `localhost` will be used as hostname.
81+
7282
## Usage
7383

7484
To generate a PNG file of a Plotly plot, just send an HTTP POST request to the

0 commit comments

Comments
 (0)