forked from ethersphere/bee-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.js
executable file
·35 lines (30 loc) · 812 Bytes
/
serve.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
const path = require('path')
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' }],
headers: [
{
source: '*',
headers: [
{
key: 'Cache-Control',
value: 'max-age=3600',
},
],
},
],
}
const server = http.createServer((request, response) => {
return handler(request, response, serverConfig)
})
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:${port}`)
})