Next.js Discord

Discord Forum

make server component run everytiem i click on a Link or sth

Answered
Bully Kutta posted this in #help-forum
Open in Discord
Bully KuttaOP
so i have a Middleware server component that validates sum cookies in my root layot
and if a user clicks on a Link which sends them to a diff page my server component doesnt get re-executed
how do i make it re-execute?
i cant use middleware because i have to make prisma calls to validate the cookie
Answered by "use php"
Middleware doesn't execute again, if you're redirecting to the same page using <Link>, as If I'm right, it displays the cached content.
View full answer

31 Replies

Answer
how do i make it execute again
can i?
i could use effect and a client component i think
but
i dont wanna make a whole ass api route to validate this cookie
fok this
Umm, I'm not sure if there is a need to execute it again, because if its validated once, then the token will most likely be valid for rest of the session
In very rare cases, It'll get invalidated, where you can redirect user to login
so i go to /
If you want to still do it, then I'm not sure, but revalidatePage should work
Bully KuttaOP
and form there a Link leads me to dashboard
ykw
nvm
fuck this
the only way for a token to get invalidated
is for the user to do some fuckery with dev tools
if they do fuckery with dev tools and the site stops working
exactly
Bully KuttaOP
ITS ON THEM
I AINT RESPONSIBLE
@Bully Kutta ITS ON THEM
But if it even expires on rare cases, just router.refresh()
Bully KuttaOP
yeh
thanks
Feel free to ping me in any other thread if you need help with any other query!
Bully KuttaOP
thank you so much man
lol