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

[sitecore-jss-proxy] Setting "followRedirects" to true" breaks HEAD requests #1630

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

illiakovalenko
Copy link
Contributor

@illiakovalenko illiakovalenko commented Oct 12, 2023

Description / Motivation

When customers use followRedirects: true and try to send a HEAD request, the proxy server crashes.
This PR addresses this problem. When followRedirects is enabled, http-proxy-middleware initializes a proxy request before onProxyReq is called, after it's initialized there is no way to update the method without accessing to internal properties, so we swap HEAD with GET before onProxyReq is called, and change it back in onProxyReq event in case it's accessed later.

This change shouldn't be treated as a breaking change, since Express middleware accepts an array of handlers also.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

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 change)

@illiakovalenko illiakovalenko changed the title [sitecore-jss-proxy] Setting "followRedirects" to true" breaks HEAD requests. [sitecore-jss-proxy] Setting "followRedirects" to true" breaks HEAD requests Oct 12, 2023
@illiakovalenko illiakovalenko requested a review from a team October 12, 2023 07:54
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.

2 participants