Move port and hostname to the server object

This commit is contained in:
Louis Lam
2023-10-10 03:15:10 +08:00
parent d4f9acee6a
commit 5fa2fcb0d9
3 changed files with 49 additions and 23 deletions

View File

@@ -133,10 +133,13 @@ router.post("/api", headerAuthMiddleware, async (request, response) => {
const requestData = request.body;
console.log(requestData);
let hostname = "localhost";
if (server.hostname) {
hostname = server.hostname;
}
const protocol = (server.isHTTPS) ? "wss" : "ws";
// TODO: should not hard coded
let wsURL = "ws://localhost:3001";
let wsURL = `${protocol}://${hostname}:${server.port}`;
const socket = ioClient(wsURL, {
transports: [ "websocket" ],