mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: https://github.com/vercel/next.js/issues/15118 Fixes: https://github.com/vercel/next.js/issues/32824 Closes: https://github.com/vercel/next.js/pull/33129
21 lines
437 B
JavaScript
21 lines
437 B
JavaScript
export async function getServerSideProps(context) {
|
|
return {
|
|
props: (async function () {
|
|
// Mimic some async work, like getting data from an API
|
|
await new Promise((resolve) => setTimeout(resolve))
|
|
context.res.setHeader('test-header', 'this is a test header')
|
|
return {
|
|
text: 'res',
|
|
}
|
|
})(),
|
|
}
|
|
}
|
|
|
|
export default ({ text }) => {
|
|
return (
|
|
<>
|
|
<div>hello {text}</div>
|
|
</>
|
|
)
|
|
}
|