fix socket.io path

This commit is contained in:
Jakub Blažej 2021-12-24 12:31:09 +01:00
parent c8d729883c
commit c165f6cad9
2 changed files with 6 additions and 5 deletions

View file

@ -123,7 +123,7 @@ if (sslKey && sslCert) {
server = http.createServer(app);
}
const io = new Server(server, {path: basePath + '/socket.io'});
const io = new Server(server, {path: basePath + 'socket.io'});
module.exports.io = io;
// Must be after io instantiation
@ -203,9 +203,9 @@ exports.entryPage = "dashboard";
// Entry Page
mainRouter.get("/", async (_request, response) => {
if (exports.entryPage === "statusPage") {
response.redirect("status");
response.redirect(basePath + "status");
} else {
response.redirect("dashboard");
response.redirect(basePath + "dashboard");
}
});

View file

@ -67,11 +67,12 @@ export default {
wsHost = protocol + location.host;
}
const urlBase = document.querySelector("head base").getAttribute("href");
// always starts and ends with '/'
const basePath = document.querySelector("head base").getAttribute("href");
socket = io(wsHost, {
transports: ["websocket"],
path: urlBase + "/socket.io"
path: basePath + "socket.io"
});
socket.on("info", (info) => {