N
Nuxt8mo ago
Rdd0u

Redirect from nitro middleware

Hi, I am planning to build an app with nitro and some good old server side rendered html with pug templates enhanced with htmx. As many apps I will have an onboarding flow and plan on maintaining a flag of the onboarding status in the session token. If a user is trying to access a dashboard page whilst not being onboarded I want to redirect him to... the onboarding page. A good place to do that would seem to be a middleware. However, h3/nitro docs mention Middleware must not return any value or directly return a response for event. So would using a sendRedirect() if onboarded === false in a middleware be bad practice? If so, what would be the best to handle this use case? Adding to the context and verifying the flag in each handler seems.... counter productive. Thanks
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server