Next.js Discord

Discord Forum

Server Actions & Middleware: Redirect doesn't work on POST method

Unanswered
Southern rough shrimp posted this in #help-forum
Open in Discord
Southern rough shrimpOP
Hello, in my middleware I have an auth check on private routes, which redirects the user to the login page if they fail the check.
when a user stays still on a page long enough to have his token expire, but then he comes back and fires a server action, that server action get's caught in the middleware, and the middleware tries to return a redirect response. but because this is a POST method and not a GET, the redirect doesn't work.

any ideas on how to tackle this?

0 Replies