Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix loader request on document POST requests #9721

Merged
merged 6 commits into from
Dec 13, 2022

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Dec 12, 2022

Follow up to #9660 to ensure we proxy the request.headers from the action request. For document requests during SSR we also persist the method since it's a single POST request, unlike during CSR when the revalidations are separate GET requests. This matches Remix behavior in 1.7.6 but going to confirm.

Remix PR: remix-run/remix#4829

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2022

🦋 Changeset detected

Latest commit: 8db43ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Patch
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brophdawg11 brophdawg11 force-pushed the brophdawg11/ssr-document-action-loader-request branch from 2b39ae8 to 9315bf7 Compare December 12, 2022 16:54
Comment on lines 10953 to 10966
expect(rootLoaderRequest.method).toBe("GET");
expect(rootLoaderRequest.method).toBe("POST");
expect(rootLoaderRequest.url).toBe("http://localhost/child");
expect(childLoaderRequest.method).toBe("GET");
expect(rootLoaderRequest.headers.get("test")).toBe("value");
expect(await rootLoaderRequest.text()).toBe("");
expect(childLoaderRequest.method).toBe("POST");
expect(childLoaderRequest.url).toBe("http://localhost/child");
expect(childLoaderRequest.headers.get("test")).toBe("value");
// Can't re-read body here since it's the same request as the root
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because query is a single document-level POST request the loaders reflect POST as well, but we don't proxy along the body

Copy link
Collaborator

@chaance chaance left a comment

Choose a reason for hiding this comment

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

Looks and sounds good but I don't think I'm familiar enough with what should be correct behavior here to approve 😅

method: request.method,
redirect: request.redirect,
signal: request.signal,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the moment we are not persisting method:'POST' as Remix did since we think that should be changed in Remix

@brophdawg11 brophdawg11 merged commit e54fbab into dev Dec 13, 2022
@brophdawg11 brophdawg11 deleted the brophdawg11/ssr-document-action-loader-request branch December 13, 2022 15:34
Copy link
Contributor

🤖 Hello there,

We just published version 6.25.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.25.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants