Rdd0u
Rdd0u
NNuxt
Created by Rdd0u on 6/3/2024 in #❓・help
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,
1 replies
NNuxt
Created by Rdd0u on 5/6/2024 in #❓・help
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
1 replies
NNuxt
Created by Rdd0u on 3/29/2023 in #❓・help
Cloud functions location
Hello, Is there an option to configure the location of the cloudfunction used by Nitro when deploying on firebase? What I want for instance is to make sure the server function is deployed in europe, and not us-central1 by default. Thanks
1 replies