Next.js Discord

Discord Forum

Issue with first initial render after build

Unanswered
Cuvier’s Dwarf Caiman posted this in #help-forum
Open in Discord
Cuvier’s Dwarf CaimanOP
Server-Side
I am extracting host from the context.ctx.req.headers and sending it down as a part pageProps using getInitialProps in _app.tsx.
[code URL: https://github.com/Shreyaschorge/web-app-clone/blob/aff247d119974cf9720719c44d328e98e4abdb39/pages/_app.tsx#L354]

Client-Side
I am getting the host from the pageProps and logging it to the console. [code URL: https://github.com/Shreyaschorge/web-app-clone/blob/aff247d119974cf9720719c44d328e98e4abdb39/pages/_app.tsx#L142]

Issue
When I deploy the application on vercel, for the first initial render after build, in the logs don't run because pageProps.host = undefined after refreshing though it works even for subsequent initial renders.

2 Replies

Cuvier’s Dwarf CaimanOP
&752637460550385834
do not ping mods for code help