headers object is empty in context of getServerData
htmlObserver opened this issue · 0 comments
htmlObserver commented
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
- context.headers empty ("{}") in getServerData function.
- in v5 (tested on @r-ichard/gatsby-starter-bootstrap-5 and ond gatsby-starter-rendering-modes) both in 'gatsby serve' and 'gatsby develop' mode.
-in v4 this problem occures only in 'gatsby server' mode, 'gatsby develop' works fine.
Reproduction Link
https://github.com/r-ichard/gatsby-starter-bootstrap-5
Steps to Reproduce
- clone gatsby starter e.g. @r-ichard/gatsby-starter-bootstrap-5
- add getServerData function on any page
export async function getServerData(context) {
return {
status: 200,
props: {
headers1: context.headers,
headers2: JSON.parse(JSON.stringify(context.headers)),
},
headers: {},
}
}
- run gatsby develop
Expected Result
headers should be present in props.serverData.headers1
Actual Result
props.serverData.headers1
returns {}
Environment
System:
OS: Windows 10 10.0.19045
CPU: (4) x64 Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
Binaries:
Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 3.8.10
Browsers:
Chrome: 128.0.6613.115
Edge: Chromium (127.0.2651.74)
npmPackages:
gatsby: ^5.1.0 => 5.1.0
gatsby-plugin-gatsby-cloud: ^5.1.0 => 5.1.0
gatsby-plugin-image: ^3.1.0 => 3.1.0
gatsby-plugin-manifest: ^5.1.0 => 5.1.0
gatsby-plugin-offline: ^6.1.0 => 6.1.0
gatsby-plugin-sass: ^6.1.0 => 6.1.0
gatsby-plugin-sharp: ^5.1.0 => 5.1.0
gatsby-source-filesystem: ^5.1.0 => 5.1.0
gatsby-transformer-sharp: ^5.1.0 => 5.1.0
Config Flags
No response