Node 18.19.1 (Netlify / Local)
NextJS 14.1.0
My app works perfectly fine locally, including building a production version and running locally using:
yarn build
yarn start
The following issue only happens when deployed to Netlify.
The Issue
Structure (of relevance):
pages/_app.tsx
pages/index.tsx
uses getServerSideProps
When the page is first loaded the pageProps within _app.tsx is present and the index.tsx receives these fine and is able to render the page.
There is a <Link />
on the page which directs the user back to the root of the app /
.
<Link href="/" className="flex-shrink-0">
<Image
src={logo}
alt="Logo"
height={40}
width={256}
/>
</Link>
When the user clicks this link, it causes the page to be re-rendered. I can see in the Network tab that index.json is fetched from /_next/data/<BUILD_ID>/index.json
but its contents is simply {}
and the page now breaks as it doesn’t have its props that were there originally on the first page load.
On my local machine, that same index.json request after clicking the <Link />
contains all the data expected that were returned from the initial getServerSideProps
call.
Here’s an example of the site:
https://deploy-preview-101--dovu-marketplace-staging.netlify.app/
Click the logo in the top left and see that the index.json file in the Network tab returning {}
and the carousel slider disappearing because it doesn’t have the props required to render them.
This feels like I’ve got my Netlify environment misconfigured or there is some edge case I’m not aware of. Any thoughts or things to try would be appreciated. I’ve run out of ideas!
Thanks