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)
|
||||
|
||||
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
|
||||
|
||||
To build Docker image and run it, execute the following from inside project directory:
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const path = require('path')
|
||||
const handler = require('serve-handler');
|
||||
const http = require('http');
|
||||
const handler = require('serve-handler')
|
||||
const http = require('http')
|
||||
const opener = require('opener')
|
||||
|
||||
const port = process.env.PORT || 8080
|
||||
|
||||
const serverConfig = {
|
||||
public: path.join(__dirname, 'build'),
|
||||
trailingSlash: false,
|
||||
rewrites: [
|
||||
{ source: "**", destination: "/index.html" },
|
||||
],
|
||||
rewrites: [{ source: '**', destination: '/index.html' }],
|
||||
headers: [
|
||||
{
|
||||
source: "*",
|
||||
headers: [{
|
||||
key: "Cache-Control",
|
||||
value: "max-age=3600"
|
||||
}]
|
||||
}
|
||||
]
|
||||
{
|
||||
source: '*',
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'max-age=3600',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const server = http.createServer((request, response) => {
|
||||
return handler(request, response, serverConfig)
|
||||
})
|
||||
|
||||
return handler(request, response, serverConfig);
|
||||
})
|
||||
|
||||
server.listen(8080, () => {
|
||||
console.log('Starting up Bee Dashboard on address http://localhost:8080')
|
||||
server.listen(port, () => {
|
||||
console.log(`Starting up Bee Dashboard on address http://localhost:${port}`)
|
||||
console.log('Hit CTRL-C to stop the server')
|
||||
opener('http://localhost:8080')
|
||||
opener(`http://localhost:${port}`)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user