latest changes before server transfer
Some checks failed
Deploy to Firebase Hosting on merge / build_and_deploy (push) Has been cancelled
Some checks failed
Deploy to Firebase Hosting on merge / build_and_deploy (push) Has been cancelled
This commit is contained in:
32
server/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
32
server/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
exports.merge = require('utils-merge');
|
||||
|
||||
/**
|
||||
* Reconstructs the original URL of the request.
|
||||
*
|
||||
* This function builds a URL that corresponds the original URL requested by the
|
||||
* client, including the protocol (http or https) and host.
|
||||
*
|
||||
* If the request passed through any proxies that terminate SSL, the
|
||||
* `X-Forwarded-Proto` header is used to detect if the request was encrypted to
|
||||
* the proxy, assuming that the proxy has been flagged as trusted.
|
||||
*
|
||||
* @param {http.IncomingMessage} req
|
||||
* @param {Object} [options]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
exports.originalURL = function(req, options) {
|
||||
options = options || {};
|
||||
var app = req.app;
|
||||
if (app && app.get && app.get('trust proxy')) {
|
||||
options.proxy = true;
|
||||
}
|
||||
var trustProxy = options.proxy;
|
||||
|
||||
var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
|
||||
, tls = req.connection.encrypted || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0])
|
||||
, host = (trustProxy && req.headers['x-forwarded-host']) || req.headers.host
|
||||
, protocol = tls ? 'https' : 'http'
|
||||
, path = req.url || '';
|
||||
return protocol + '://' + host + path;
|
||||
};
|
||||
Reference in New Issue
Block a user