Files
bee-dashboard/serve.js
T
Matt Mertens ba9b498488 fix: replace http-serve with serve-handler (#122)
* fix: replace http-serve with serve package

Replaces the http-serve package to properly handle the single page routing

* feat: add cache invalidation

* fix: add serve command in bin

* fix: remove serve package dependency

* chore: applied PR review suggestions

Co-authored-by: Vojtech Simetka <vojtech@simetka.cz> (+1 squashed commit)
Squashed commits:
[d73baf4] Update serve.js

Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>

Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
2021-05-31 09:57:44 +02:00

35 lines
768 B
JavaScript

#!/usr/bin/env node
const path = require('path')
const handler = require('serve-handler');
const http = require('http');
const opener = require('opener')
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(8080, () => {
console.log('Starting up Bee Dashboard on address http://localhost:8080')
console.log('Hit CTRL-C to stop the server')
opener('http://localhost:8080')
})