feat: allow for the port to be configured (#370)
* feat: allow for the port to be configured * feat: default to port 8080 if there is no other port provided
This commit is contained in:
@@ -60,6 +60,15 @@ bee-dashboard
|
|||||||
|
|
||||||
This should open the webpage on [`http://localhost:8080`](http://localhost:8080)
|
This should open the webpage on [`http://localhost:8080`](http://localhost:8080)
|
||||||
|
|
||||||
|
You can also define your own port with the `PORT` environment variable. E.g.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export PORT=3005
|
||||||
|
bee-dashboard
|
||||||
|
```
|
||||||
|
|
||||||
|
Will start the bee-dashboard on [`http://localhost:3005`](http://localhost:3005)
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
To build Docker image and run it, execute the following from inside project directory:
|
To build Docker image and run it, execute the following from inside project directory:
|
||||||
|
|||||||
@@ -1,34 +1,35 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const handler = require('serve-handler');
|
const handler = require('serve-handler')
|
||||||
const http = require('http');
|
const http = require('http')
|
||||||
const opener = require('opener')
|
const opener = require('opener')
|
||||||
|
|
||||||
|
const port = process.env.PORT || 8080
|
||||||
|
|
||||||
const serverConfig = {
|
const serverConfig = {
|
||||||
public: path.join(__dirname, 'build'),
|
public: path.join(__dirname, 'build'),
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
rewrites: [
|
rewrites: [{ source: '**', destination: '/index.html' }],
|
||||||
{ source: "**", destination: "/index.html" },
|
|
||||||
],
|
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
source: "*",
|
source: '*',
|
||||||
headers: [{
|
headers: [
|
||||||
key: "Cache-Control",
|
{
|
||||||
value: "max-age=3600"
|
key: 'Cache-Control',
|
||||||
}]
|
value: 'max-age=3600',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = http.createServer((request, response) => {
|
const server = http.createServer((request, response) => {
|
||||||
|
return handler(request, response, serverConfig)
|
||||||
|
})
|
||||||
|
|
||||||
return handler(request, response, serverConfig);
|
server.listen(port, () => {
|
||||||
})
|
console.log(`Starting up Bee Dashboard on address http://localhost:${port}`)
|
||||||
|
|
||||||
server.listen(8080, () => {
|
|
||||||
console.log('Starting up Bee Dashboard on address http://localhost:8080')
|
|
||||||
console.log('Hit CTRL-C to stop the server')
|
console.log('Hit CTRL-C to stop the server')
|
||||||
opener('http://localhost:8080')
|
opener(`http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user