added wrapper to getInitialProps to prevent api calls in production
This commit is contained in:
1 parent
dded475c47
commit
fe5cc36182
12 files changed
+49
-33
No files matched your search
+3
-3
@@ -6,7 +6,7 @@ import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
import { Meta } from '../src/components/Meta'
|
||||
import { meta } from '../src/lib/meta'
|
||||
import { createApiUrl, requestGet } from '../src/next-lib'
|
||||
import { createApiUrl, requestGet, wrapInitialProps } from '../src/next-lib'
|
||||
|
||||
const Index = (props) => (
|
||||
<App
|
||||
@@ -29,7 +29,7 @@ const Index = (props) => (
|
||||
</App>
|
||||
)
|
||||
|
||||
Index.getInitialProps = async (ctx) => {
|
||||
Index.getInitialProps = wrapInitialProps(async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
// // const pageUrl = '/neighbors/2018'
|
||||
const page = await requestGet(createApiUrl(ctx.req, `/api/page?page=${pageUrl}`), {})
|
||||
@@ -46,6 +46,6 @@ Index.getInitialProps = async (ctx) => {
|
||||
imageHeight: image.height,
|
||||
}),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default Index
|
||||
Reference in new issue
Block a user