Fixed http to https redirection.

This commit is contained in:
Ylian Saint-Hilaire 2019-10-25 16:32:09 -07:00
parent 6aa755dca7
commit 74539037da
3 changed files with 4 additions and 10 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.4.3-e",
"version": "0.4.3-f",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -32,16 +32,10 @@ module.exports.CreateRedirServer = function (parent, db, args, func) {
// Perform an HTTP to HTTPS redirection
function performRedirection(req, res) {
var host = req.headers.host;
if (obj.certificates != null) {
host = obj.certificates.CommonName;
if (obj.certificates.CommonName.indexOf('.') == -1) { host = req.headers.host; }
}
if (typeof host == 'string') { host = host.split(":")[0]; }
if ((host == null) && (obj.certificates != null)) { host = obj.certificates.CommonName; if (obj.certificates.CommonName.indexOf('.') == -1) { host = req.headers.host; } }
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
if (req.headers && req.headers.host && (req.headers.host.split(":")[0].toLowerCase() == "localhost")) {
res.redirect("https://localhost:" + httpsPort + req.url);
} else {
res.redirect("https://" + host + ":" + httpsPort + req.url);
}
res.redirect("https://" + host + ":" + httpsPort + req.url);
}
/*