Skip to content

Commit

Permalink
fix: Omit standard protocol ports from the default hostname (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
compwright authored and daffl committed Sep 6, 2019
1 parent 19259dd commit ef16d29
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/authentication-oauth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,32 @@ export const setup = (options: OauthSetupSettings) => (app: Application) => {
}

const { strategyNames } = service;

// Set up all the defaults
const { path = '/oauth' } = oauth.defaults || {};
const port = app.get('port');
let host = app.get('host');
let protocol = 'https';

// Development environments commonly run on HTTP with an extended port
if (app.get('env') === 'development') {
protocol = 'http';
if (String(port) !== '80') {
host += ':' + port;
}
}

const grant = merge({
defaults: {
path,
host: `${app.get('host')}:${app.get('port')}`,
protocol: app.get('env') === 'production' ? 'https' : 'http',
host,
protocol,
transport: 'session'
}
}, omit(oauth, 'redirect'));

const getUrl = (url: string) => {
const { defaults } = grant;

return `${defaults.protocol}://${defaults.host}${path}/${url}`;
};

Expand Down

0 comments on commit ef16d29

Please sign in to comment.