Skip to content

Commit

Permalink
Get protocol primarily from OAUTH2_CALLBACK_URL env
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Nov 9, 2023
1 parent f1d8c04 commit 35f6ef4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const BASEPATH = process.env.LTC_BASEPATH;

const add_layman_proxy_headers = (proxyReq, req, res) => {
authn_util.add_authn_headers(proxyReq, req, res);
proxyReq.setHeader('X-Forwarded-Proto', req.protocol);
const protoFromEnv = process.env.OAUTH2_CALLBACK_URL ? new URL(process.env.OAUTH2_CALLBACK_URL).protocol.slice(0, -1) : null;
proxyReq.setHeader('X-Forwarded-Proto', protoFromEnv || req.protocol);
proxyReq.setHeader('X-Forwarded-Host', req.get('host'));
proxyReq.setHeader('X-Forwarded-Prefix', BASEPATH);
}
Expand Down

0 comments on commit 35f6ef4

Please sign in to comment.