After logging in a user, I would like to redirect them to the last visited store page. I am using the Customer Account API’s (2024-10) login()
method. The docs state a return_to
parameter is being automatically set unless customAuthStatusHandler
is used, which I am not.
So for example, if a user happens to be on a product page and hits the login button in the navbar, I would like to pass the pathname of this current product page to the login function, so when the user is logged in, they get redirected to the page they were before.
As it is right now when using the auth routes setup from the skeleton template, the user gets redirected to the /account
route. This is suboptimal user experience.
Is there any way to set the redirect path?