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 concatenating requests #2536

Merged
merged 1 commit into from
Sep 1, 2023
Merged

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Sep 1, 2023

Description

Concatenating requests is broken, which is sometimes important for proxying one route to another. This fixes it in a somewhat hacky, but less likely to break other things, way by simply adding a header. This can be tested by booting up the playground and navigating to /concatenate, notice the /about route is rendered. There's also an e2e test that validates it.

Additional context


Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@@ -299,7 +299,7 @@ export async function renderApiRoute(
return new Request(getRscUrl(url, newUrl), {
headers: response.headers,
});
} else {
} else if (!response.headers.get('hydrogen-concatenate')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is line 310 returns a response, and we don't want to get into this crazy form logic. So if this header is present, just return the response on 317. But because the response is really a Request instance, Hydrogen already has functionality to properly process the new Request without actually making a new network request.

@blittle blittle merged commit 532c5f3 into v1.x-2022-07 Sep 1, 2023
7 checks passed
@blittle blittle deleted the bl-fix-concatenate-requests branch September 1, 2023 17: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