Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: replace http-serve with serve package #122

Merged
merged 5 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
"axios": "^0.21.1",
"bignumber.js": "^9.0.1",
"feather-icons": "^4.28.0",
"http-serve": "^1.0.1",
"material-ui-dropzone": "^3.5.0",
"opener": "^1.5.2",
"qrcode.react": "^1.0.1",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^17.0.2",
"react-feather": "^2.0.9",
"react-identicons": "^1.2.5",
"react-router-dom": "^5.2.0",
"react-syntax-highlighter": "^15.4.3"
"react-syntax-highlighter": "^15.4.3",
"serve": "^11.3.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.12.0",
Expand Down Expand Up @@ -70,7 +71,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"serve": "http-serve ./build -o",
"serve": "serve build --single --listen 8080",
"lint": "eslint --fix \"src/**/*.ts\" \"src/**/*.tsx\" && prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
"lint:check": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" && prettier --check \"src/**/*.ts\" \"src/**/*.tsx\""
},
Expand Down
12 changes: 12 additions & 0 deletions public/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"trailingSlash": false,
"headers": [
{
"source" : "*",
"headers" : [{
"key" : "Cache-Control",
"value" : "max-age=3600"
}]
}
]
}
30 changes: 24 additions & 6 deletions serve.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/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) => {

server.listen(8080, '127.0.0.1', function () {
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')
})
});