Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add x-forwarded-port and x-forwarded-proto to proxyHeaderIgnore defaults #465

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/en/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ This also helps making consistent requests in both SSR and Client Side code.

## `proxyHeadersIgnore`

* Default `['accept', 'host', 'x-forwarded-host', 'cf-ray', 'cf-connecting-ip', 'content-length', 'content-md5', 'content-type']`
* Default `['accept', 'host', 'x-forwarded-host', 'x-forwarded-port', 'x-forwarded-proto', 'cf-ray', 'cf-connecting-ip', 'content-length', 'content-md5', 'content-type']`
pi0 marked this conversation as resolved.
Show resolved Hide resolved

This is useful and effective only when `proxyHeaders` is set to true. It removes unwanted requests headers to the API backend in SSR.

Ignoring the headers `x-forwarded-host`, `cf-ray`, and `cf-connecting-ip` is necessary to avoid confusing reverse proxies (including CloudFlare) and avoid causing proxy loops.
Ignoring headers like `x-forwarded-host` is necessary to avoid confusing reverse proxies (like Nginx and CloudFlare) and avoid causing proxy loops.

## `headers`

Expand Down
13 changes: 12 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ function axiosModule (_moduleOptions) {
debug: false,
progress: true,
proxyHeaders: true,
proxyHeadersIgnore: ['accept', 'host', 'x-forwarded-host', 'cf-ray', 'cf-connecting-ip', 'content-length', 'content-md5', 'content-type'],
proxyHeadersIgnore: [
'accept',
'cf-connecting-ip',
'cf-ray',
'content-length',
'content-md5',
'content-type',
'host',
'x-forwarded-host',
'x-forwarded-port',
'x-forwarded-proto'
],
proxy: false,
retry: false,
https,
Expand Down