Next.js Discord

Discord Forum

router.replace('...', { scroll: false }) causes page reload in prod, but not locally

Unanswered
Atlantic menhaden posted this in #help-forum
Open in Discord
Atlantic menhadenOP
I have a Next.js 14 app that uses the app router, and useRouter from next/navigation. On the home page I have a list of items that, when clicked, should update the query string in the URL without reloading the page. I use a router.replace('...', { scroll: false }) call to do this. This works as expected when running npm run dev locally, but not in live. The app is deployed as a Docker container using the Dockerfile example here https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile. Could it be to do with the app running in standalone mode?

The app is deployed to AWS Fargate and sits behind a Cloudfront distribution. If I access the deployed app from the load balancer directly, I don't get the issue, but from Cloudfront the page reloads on clicking an item.

0 Replies