I have a NextJS app deployed on a Kubernetes Cluster. My app handles redirects (Same website, different path) based on business logic and i was wondering if there is a possibility to handle that "redirect" (im using router.push from useRouter) in the same pod.
What happens is that when the first request comes in, POD#1 handle it, when a redirect is detected, then the logic fires router.push and that redirect its been handled by POD#2.
What you could do is to configure on your load balancer "sticky sessions" to make sure requests from a client goes to the same node.
And then using anti-affinity rules, make sure you don't deploy more than 1 pod of your app per node
Anyway, make sure your requests are stateless as possible, except for some caching optimisation it shouldn't matter which pod the request hits.