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); 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; module.exports.io = io;
// Must be after io instantiation // Must be after io instantiation
@ -203,9 +203,9 @@ exports.entryPage = "dashboard";
// Entry Page // Entry Page
mainRouter.get("/", async (_request, response) => { mainRouter.get("/", async (_request, response) => {
if (exports.entryPage === "statusPage") { if (exports.entryPage === "statusPage") {
response.redirect("status"); response.redirect(basePath + "status");
} else { } else {
response.redirect("dashboard"); response.redirect(basePath + "dashboard");
} }
}); });

View file

@ -67,11 +67,12 @@ export default {
wsHost = protocol + location.host; 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, { socket = io(wsHost, {
transports: ["websocket"], transports: ["websocket"],
path: urlBase + "/socket.io" path: basePath + "socket.io"
}); });
socket.on("info", (info) => { socket.on("info", (info) => {