-
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.
Update to not modify req.url for getServerSideProps requests (#11637)
- Loading branch information
Showing
5 changed files
with
93 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 |
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