Next.js Discord

Discord Forum

Weird router caching error in remote / mvp but works in localhost?

Unanswered
Phalène posted this in #help-forum
Open in Discord
PhalèneOP
Using Auth.js to sign out from a protected page and reroute to main landing page. On localhost, everything works as expected i.e. user usage menu in navbar is cleared and sub-component toggles to sign in page.

When deploying to production (SST/ AWS), sign out works, but when I return to the page with sign-in / user usage menu, the usage stats remain.

<snippet>
const handleSignOutClick = async () => {
setIsSigningOut(true); // Indicate loading state
try {
// 1. Call NextAuth's signOut.
await signOut({ redirect: false });
// 2. Invalidate the Next.js Router Cache for the current route segment.
router.refresh();
// 3. Redirect the user to a public page (e.g., the homepage).
router.push('/');
} catch (error) {
console.error("Sign out error:", error);
// Optionally display an error message to the user
setIsSigningOut(false); // Reset button state on error
}
};
</snippet>

Any tips or tricks to completely clear caches? I've already used claude and google studio.

2 Replies

Sphecid wasp
What do you mean "usage stats"? Do you have any code you can show us?
PhalèneOP
Ignore my request, seems the issue is related to an unresolved issue with Auth.js not Next.js. Thanks!