From be85c246ff1ff95dee8d0b3da25e0af84c0481b5 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 26 Oct 2023 15:27:27 +0530 Subject: [PATCH] fix(socketio): send correct url for auth in case, an app uses a different frontend stack on a different development server, socketio should use the correct webserver port when authenticating --- realtime/utils.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/realtime/utils.js b/realtime/utils.js index 0ff3be0a49..85df2f9157 100644 --- a/realtime/utils.js +++ b/realtime/utils.js @@ -1,8 +1,19 @@ +const { get_conf } = require("../node_utils"); +const conf = get_conf(); + function get_url(socket, path) { if (!path) { path = ""; } - return socket.request.headers.origin + path; + let url = socket.request.headers.origin; + if (conf.developer_mode) { + let [protocal, host, port] = url.split(':'); + if (port != conf.webserver_port) { + port = conf.webserver_port; + } + url = `${protocal}:${host}:${port}`; + } + return url + path; } module.exports = {