-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cookies and headers for request using in RSC (#31623)
* Passdown the request with richer information * test: access request header as prop from gSSP
- Loading branch information
Showing
5 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
test/integration/react-streaming-and-server-components/app/pages/index.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
import Foo from '../components/foo.client' | ||
|
||
const envVar = process.env.ENV_VAR_TEST | ||
const headerKey = 'x-next-test-client' | ||
|
||
export default function Index() { | ||
export default function Index({ header, router }) { | ||
return ( | ||
<div> | ||
<h1>{`thisistheindexpage.server`}</h1> | ||
<div>{envVar}</div> | ||
<h1>{`component:index.server`}</h1> | ||
<div>{'path:' + router.pathname}</div> | ||
<div>{'env:' + envVar}</div> | ||
<div>{'header:' + header}</div> | ||
<div> | ||
<Foo /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export function getServerSideProps({ req }) { | ||
const { headers } = req | ||
const header = headers.get(headerKey) | ||
|
||
return { | ||
props: { | ||
header, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters