File size: 586 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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
|