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

feat: revalidate on redirect if cookies were set #2370

Merged
merged 3 commits into from
Mar 21, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
oops, forgot to commit a file
  • Loading branch information
jacob-ebey committed Mar 20, 2022
commit 0046b1b25bb3fdfa0feccaab269506bf28848439
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async function handleDataRequest({
headers.set("X-Remix-Redirect", headers.get("Location")!);
headers.delete("Location");
if (response.headers.get("Set-Cookie") !== null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

In the browser, you can not access response.headers.get("Set-Cookie") to determine if a cookie was set in the response when credentials: "same-origin" is set. To avoid having to set it to credentials: "include" and adding additional CORS headers, this is my workaround.

Copy link
Member

Choose a reason for hiding this comment

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

Seems fine to me, maybe X-Remix-Revalidate instead incase we discover other reasons to revalidate we can use the same mechanism?

headers.set("X-Remix-Set-Cookie", "yes");
headers.set("X-Remix-Revalidate", "yes");
}

return new Response(null, {
Expand Down