Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Use req.hostname for hostname query in axios client #1221

Merged
merged 2 commits into from
Jan 15, 2019

Conversation

christinebrass
Copy link
Contributor

This will ensure that the value of X-Forwarded-Host is used whenever trust proxy is enabled, falling back to the normal host header when it is disabled.

This will ensure that the value of X-Forwarded-Host is used whenever
trust proxy is enabled, falling back to the normal host header when it
is disabled.
@@ -47,7 +47,7 @@ export default function getHttpClient(
// If a request object is provided, then we want to merge the custom headers
// with the headers that we sent from the browser in the request.
client = httpClient.create({
baseURL: protocol + req.headers.host,
baseURL: protocol + req.hostname,
Copy link
Contributor Author

@christinebrass christinebrass Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fall back to req.get('host') when trust proxy is not enabled:

https://github.com/expressjs/express/blob/4.16.4/lib/request.js#L431-L433

Copy link
Collaborator

@threehams threehams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches app changes.

@christinebrass christinebrass merged commit f04310c into develop Jan 15, 2019
@christinebrass christinebrass deleted the hostname-changes branch January 15, 2019 01:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants