mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +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
30 lines
586 B
JavaScript
30 lines
586 B
JavaScript
import App from 'next/app'
|
|
|
|
class MyApp extends App {
|
|
static async getInitialProps(ctx) {
|
|
const { req, query, pathname, asPath } = ctx.ctx
|
|
let pageProps = {}
|
|
|
|
if (ctx.Component.getInitialProps) {
|
|
pageProps = await ctx.Component.getInitialProps(ctx.ctx)
|
|
}
|
|
|
|
return {
|
|
appProps: {
|
|
url: (req || {}).url,
|
|
query,
|
|
pathname,
|
|
asPath,
|
|
},
|
|
pageProps,
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { Component, pageProps, appProps } = this.props
|
|
return <Component {...pageProps} appProps={appProps} />
|
|
}
|
|
}
|
|
|
|
export default MyApp
|