mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Make HTTPS compatible with a Ghost module
closes #4434 - Change an incorrect redirect
This commit is contained in:
parent
e07ec3ef84
commit
094d6dfc38
1 changed files with 13 additions and 4 deletions
|
@ -178,6 +178,7 @@ function checkSSL(req, res, next) {
|
||||||
if (isSSLrequired(res.isAdmin)) {
|
if (isSSLrequired(res.isAdmin)) {
|
||||||
if (!req.secure) {
|
if (!req.secure) {
|
||||||
var forceAdminSSL = config.forceAdminSSL,
|
var forceAdminSSL = config.forceAdminSSL,
|
||||||
|
configUrl,
|
||||||
redirectUrl;
|
redirectUrl;
|
||||||
|
|
||||||
// Check if forceAdminSSL: { redirect: false } is set, which means
|
// Check if forceAdminSSL: { redirect: false } is set, which means
|
||||||
|
@ -186,12 +187,20 @@ function checkSSL(req, res, next) {
|
||||||
return res.sendStatus(403);
|
return res.sendStatus(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectUrl = url.parse(config.urlSSL || config.url);
|
configUrl = url.parse(config.urlSSL || config.url);
|
||||||
|
|
||||||
|
redirectUrl = configUrl.path;
|
||||||
|
if (req.url[0] === '/' && redirectUrl[redirectUrl.length - 1] === '/') {
|
||||||
|
redirectUrl += req.url.slice(1);
|
||||||
|
} else {
|
||||||
|
redirectUrl += req.url;
|
||||||
|
}
|
||||||
|
|
||||||
return res.redirect(301, url.format({
|
return res.redirect(301, url.format({
|
||||||
protocol: 'https:',
|
protocol: 'https:',
|
||||||
hostname: redirectUrl.hostname,
|
hostname: configUrl.hostname,
|
||||||
port: redirectUrl.port,
|
port: configUrl.port,
|
||||||
pathname: req.path,
|
pathname: redirectUrl,
|
||||||
query: req.query
|
query: req.query
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue