Improve proto recognition
This commit is contained in:
parent
1dba36bc62
commit
f1cc110ef4
1 changed files with 6 additions and 1 deletions
|
@ -1,4 +1,9 @@
|
|||
module.exports = function(req) {
|
||||
let proto = req.connection.encrypted || process.env.SSL === 'true' ? 'https' : 'http';
|
||||
const isConnectionEncrypted = req.connection.encrypted;
|
||||
const isSslEnvSet = process.env.SSL === 'true';
|
||||
const isHeaderSsl = req.header('X-Forwaded-Proto') === 'https';
|
||||
|
||||
const proto = isConnectionEncrypted || isSslEnvSet || isHeaderSsl ? 'https' : 'http';
|
||||
|
||||
return proto.split(/\s*,\s*/)[0];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue