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:
Vojtech Simetka
2022-05-19 11:37:54 +02:00
committed by GitHub
parent 145ebc1232
commit b6f138b423
2 changed files with 29 additions and 19 deletions
+20 -19
View File
@@ -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}`)
})