client options

This commit is contained in:
bordun 2020-03-12 12:07:58 +01:00
parent e1eb6b5df1
commit ec7147a9de
8 changed files with 38 additions and 32 deletions

View file

@ -3,6 +3,7 @@ var urlparser = require('url'),
fs = require('fs'),
send = require('send'),
http = require('http'),
replaceStream = require('replacestream'),
server = http.createServer(httpRoute),
Ipc = require('./ipc/server'),
ipc = new Ipc(server),
@ -19,14 +20,19 @@ function httpRoute(req, res) {
res.sendFile = (path)=>{
var fpath = path.split('?')[0]
if (!fs.existsSync(fpath)) throw `File "${fpath}" not found.`
send(req, fpath).pipe(res)
return send(req, fpath).pipe(res)
}
var url = req.url
if (url === '/' || url.indexOf('/?') === 0) {
res.sendFile(path.resolve(__dirname + '/../client/index.html'))
fs.createReadStream(path.resolve(__dirname + '/../client/index.html'))
.pipe(replaceStream('</body>', `<script>window.ENV=${JSON.stringify(settings.read('clientOptions'))}</script></body>`))
.pipe(res);
// res.sendFile(path.resolve(__dirname + '/../client/index.html'))
} else {