-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(server-runtime): v2_headers future flag for inheriting ancestor headers #6431
Conversation
… route doesn't export `headers` (#5473)
🦋 Changeset detectedLatest commit: bf0bfd6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
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 |
...(loaderHeaders ? Array.from(loaderHeaders.entries()) : []), | ||
...(errorHeaders ? Array.from(errorHeaders.entries()) : []), | ||
]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This existing test section is now testing the v2 behavior so removed headers
from the child. See below for specific tests that continue to assert the v1 behavior.
@@ -256,7 +245,6 @@ test.describe("headers export", () => { | |||
expect(JSON.stringify(Array.from(response.headers.entries()))).toBe( | |||
JSON.stringify([ | |||
["content-type", "text/html"], | |||
["x-child-loader", "success"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more headers from children in these tests since we're using the parent headers
function
if (routeModule.headers == null && build.future.v2_headers) { | ||
let headers = parentHeaders; | ||
prependCookies(actionHeaders, headers); | ||
prependCookies(loaderHeaders, headers); | ||
return headers; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to prependCookies
for parenHeaders
since that's what we're returning
It can be tedious and error-prone to remember to always
export function headers()
from every potential leaf route if you care about response headers on document requests. Prior to v1 the logic was to use the deepest renderableheaders
function that was found but this changed prior to v1 so we're adding it back behind a future flag for v2 to ensure no unintentional breakages in userland.We still only call
headers
for "renderable" routes (those at or above the any active error boundaries), but we'll use the deepest discoveredheaders
export, and not insist on it being a leaf.Continuation of #5473
Closes #3157