Reputation: 1364
I am experiencing something in production which isn't reproducible locally.
The Link
from nextjs (version 12.3.x
) works well in development and when running the build in production mode locally, meaning that the navigation happens without a full page reload. But when deployed with terraform, all Link
components are causing a full page reload. Everything else works as expected.
I have a mixture of Link
children across the application, sometime it's a
, but other times it's a button
or simply a div
or span
. In every case, the full page refresh happens. That's why I suspect it must be something related with the configuration rather than the Link
usage, however I am not sure where to start debugging and I am looking for a hint in the right direction.
Upvotes: 3
Views: 1894
Reputation: 1364
Back with an answer to this. In my case, nothing was wrong with the Link
components itself, nor with the build. The problem was with a path rewrite in our terraform configuration (it was rewriting everything in /_next/*
).
It appears that getServerSideProps
fetches JSON files which will be used to render the page Their paths were being re-written and causing a 403 error, which made the page reload instead of allowing me to navigate seamlessly as I am used to with next.
This problem was very specific to my configuration, but my general recommendation is to check whether you are rewriting any path of the json
files created by next at navigation, in case you are experiencing the same problem only on staging/production.
Upvotes: 2