Redirecting from middleware
Hi, the docs advise against returning a response in a middleware. https://h3.unjs.io/guide/event-handler#middleware
Middleware must not return any value or directly return a response for event. If you return a response, it will act as a normal event handler!
However, I need to redirect to a specific page if a user does not match some conditions. And this check needs to be performed on all possible server routes.
What are the possible risks/side effects of using a sendRedirect
in a middleware in that case? Or what would be the best to implement this?
Thanks,Event Handler - h3
Event handler define application logic.
0 Replies