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>
This commit is contained in:
@@ -1,15 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const path = require('path')
|
||||
const serve = require('http-serve')
|
||||
const handler = require('serve-handler');
|
||||
const http = require('http');
|
||||
const opener = require('opener')
|
||||
|
||||
const server = serve.createServer({
|
||||
root: path.join(__dirname, 'build')
|
||||
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, '127.0.0.1', function () {
|
||||
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user