diff --git a/app/connectionHandler.js b/app/connectionHandler.js index fd41f8f..5c522c5 100644 --- a/app/connectionHandler.js +++ b/app/connectionHandler.js @@ -16,10 +16,14 @@ function handleConnection(req, res, urlParams) { extend(connectionParams, req.body || {}); // Inject configuration - res.locals.webssh2Config = { + var config = { socket: { url: req.protocol + '://' + req.get('host'), path: '/ssh/socket.io' + }, + ssh: { + host: connectionParams.host || '', + port: connectionParams.port || 22 } }; @@ -32,6 +36,9 @@ function handleConnection(req, res, urlParams) { // Replace relative paths with the correct path var modifiedHtml = data.replace(/(src|href)="(?!http|\/\/)/g, '$1="/ssh/assets/'); + // Inject the configuration into the HTML + modifiedHtml = modifiedHtml.replace('window.webssh2Config = null;', 'window.webssh2Config = ' + JSON.stringify(config) + ';'); + // Send the modified HTML res.send(modifiedHtml); }); diff --git a/package-lock.json b/package-lock.json index 82902ef..69056e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4722,7 +4722,7 @@ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, "webssh2_client": { - "version": "git+ssh://git@github.com/billchurch/webssh2_client.git#6a1d9d7732c4a7404e8f276f531e66a6e4d17c56", + "version": "git+ssh://git@github.com/billchurch/webssh2_client.git#86a1131e7ce3a31803c9e6c1c416f88d68e53a01", "from": "git+ssh://git@github.com/billchurch/webssh2_client.git" }, "which": {