-
Running: Here's the permalink to the Stack Trace on Vercel
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 12 replies
-
hi @ztanner In our application, Example of condition and redirect in const isMember = false
if (!isMember) {
return NextResponse.redirect(new URL('/plans', request.url));
}
Hoping we can get a patch soon! |
Beta Was this translation helpful? Give feedback.
-
Hi @ehis, thank you for the report! This should be fixed by #65097 which is available in |
Beta Was this translation helpful? Give feedback.
-
I came across to this problem as well, IMO, having the redirects at middleware level made more sense, instead of duplicating same logic in more than one place ( one at middle ware and others at each server action ). My dependencies: in the export function middleware(request: NextRequest) {
} export const config = { |
Beta Was this translation helpful? Give feedback.
-
We're in October now, and the docs are still not updated, it should clearly reflect this conflict between server actions and running auth in middleware. Would probably save other devs from running into this.. 🙏 Thanks to finding this closed thread we were able to solve a major headache in our auth flow. We disabled middleware for server actions by checking this condition in our conditional statement: And added explicit checks in each action instead. |
Beta Was this translation helpful? Give feedback.
-
Thanks for this thread and the "work arrounds" I was pulling my hear on this one 😅 |
Beta Was this translation helpful? Give feedback.
-
I solved redirection of server actions in middleware with setting the corresponding header:
|
Beta Was this translation helpful? Give feedback.
@ehis, yep, no need to handle in middleware! You can think of it similar to an API route where you'd have the auth check at the top of the request handler.