From 04f846d494c46632a578fd27c367d714e3bd9164 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:23:09 -0600 Subject: [PATCH] fix: fixed origin mismatch (closes https://github.com/jaredhanson/passport-webauthn/issues/5) --- lib/utils.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 9f91959..909b2d7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,14 +1,3 @@ -exports.originalOrigin = 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'; - return protocol + '://' + host; +exports.originalOrigin = function(req) { + return req.origin || req.get('origin'); };