seitime-frappe/realtime/utils.js
Faris Ansari be85c246ff 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
2023-10-26 15:27:27 +05:30

21 lines
422 B
JavaScript

const { get_conf } = require("../node_utils");
const conf = get_conf();
function get_url(socket, path) {
if (!path) {
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 = {
get_url,
};