in case, an app uses a different frontend stack on a different development server, socketio should use the correct webserver port when authenticating
21 lines
422 B
JavaScript
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,
|
|
};
|