Hey, so we are trying to migrate our project from pages router to app router but we’ve been dealing with a nasty and hard-to-debug issue. We are on Next 14.2.3. If it helps, we have clientRouterFilter: false
In preview:
As you can see, when you load the page, the swr hook loads the uploaded files, as expected. Link is here: https://stackweb-7212akqiq-stack-ai.vercel.app/form/56955d69-a10f-49d9-85cc-46a6d1bd5f5a/5e662b32-89d5-432a-9251-890c3a14d6bd/67c0ca6d4df3c68b2987064f
In production:
However, in production, the files never fetch. They only get fetched when you click the page. Note, the code running here is exactly the same as the preview deployment, and this has been happening for a while only in prod. Link is here: Test Form
Network tab:
Here’s the really strange thing. This strange behavior doesn’t seem to be limited to SWR per se. In prod, even images are being refetched on click!
We know that putting use client
at the top of page.tsx
solves the issue, but we do not want to do this. We also know that importing a component as dynamic solves this, but we also do not want to do this. We want to use the SSR features of app router, and we’re really bummed that we cannot take advantage of them.
If anyone has any potential insights here, that would be amazing!