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

docs(response-interceptor.md): add headers modification example #724

Conversation

stefanwright1988
Copy link
Contributor

An update to the responseInterceptor recipe to include modifying headers

Description

The recipe file did not include an example for modifying headers.

Motivation and Context

I was working on a proof of concept at my place of work, and trying to utilise http-proxy-middleware. I was struggling with modifying the response headers, the details in https://github.com/chimurai/http-proxy-middleware#http-proxy-events worked fine if you didn't want to use the response interceptor.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [ x ] My change requires a change to the documentation.
  • I have updated the documentation accordingly.

An update to the responseInterceptor recipe to include modifying headers
@chimurai
Copy link
Owner

chimurai commented Mar 8, 2022

Hi,

The example you added is still using the responseInterceptor...

Actually, modifying header is already documented at: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md#onproxyres

@stefanwright1988
Copy link
Contributor Author

Hi,

The example you added is still using the responseInterceptor...

Actually, modifying header is already documented at: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md#onproxyres

Hi, yes sorry perhaps I was not clear, when using the responseInterceptor using proxyRes for setting the headers resulted in them not being set in the output seen in the browser. Changing to use res.setHeader() was needed when using the responseInterceptor

@coveralls
Copy link

coveralls commented Mar 8, 2022

Coverage Status

Coverage remained the same at 98.86% when pulling 07b4c97 on stefanwright1988:stefanwright1988-responseInterceptorHeadersReceipe into 2d6741a on chimurai:master.

@chimurai
Copy link
Owner

chimurai commented Mar 8, 2022

Thanks for clarifying! Think it'll helpful to have this example 👍

You might have missed some linting...
You can fix them with yarn lint:fix

@stefanwright1988
Copy link
Contributor Author

Thanks for clarifying! Think it'll helpful to have this example 👍

You might have missed some linting... You can fix them with yarn lint:fix

Thanks, I have fixed the linting issues now I believe

@chimurai chimurai changed the title Update response-interceptor.md docs(response-interceptor.md): add headers modification example Mar 10, 2022
@chimurai chimurai merged commit e9e25ca into chimurai:master Mar 10, 2022
@chimurai
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants