Redirect after a redirect not working
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
What I mean by the title is that when in my app I have a page that resets the password, on submit I call a server action which performs the api call and redirects to the
/myprofile page. Then the middleware.ts redirects to /login as the user is not logged in. The problem is that the redirect works but the url doesn't update. I am redirected to the login page but I still see /myprofile in the url. My theory for this behaviour is that the first redirect completes and sets the url, even though the middleware "iinterrupts" it and redirects it login page. Any ideas how to fix this? I want my middleware to essentially override the redirect from the page.5 Replies
Did you mean you need something like if (fromUrl to destinationUrl) don't do weird redirection?
Also give some code snippet of middleware, redirection
Also give some code snippet of middleware, redirection
Asiatic LionOP
sure
I meant that it seems like calling redirect in a server action, then middleware redirects during that redirect, there is a bug, and the url is still set to the first redirect, even though the content of the page is from the middleware redirect. I want my middleware to override or interrupt the first redirect. I don't wany my url being set to the page in the first redirect.
here's where I call the first redirect
then this is how middleware catches and redirects