-
-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Labels
bugA bug that needs to be resolvedA bug that needs to be resolvedpendingAn issue waiting for triageAn issue waiting for triage
Description
Environment
- Operating System:
Darwin
- Node Version:
v20.19.0
- Nuxt Version:
3.16.2
- CLI Version:
3.24.1
- Nitro Version:
2.11.9
- Package Manager:
[email protected]
- Builder:
-
- User Config:
compatibilityDate
,devtools
,css
,devServer
,modules
,app
,auth
,colorMode
,googleFonts
,svgo
,runtimeConfig
- Runtime Modules:
@sidebase/[email protected]
,@nuxtjs/[email protected]
,[email protected]
,[email protected]
,@nuxt/[email protected]
,[email protected]
- Build Modules:
-
Reproduction
nuxt.config.ts
globalAppMiddleware: {
isEnabled: false,
addDefaultCallbackUrl: true,
}
custom-middleware.ts
export default defineNuxtRouteMiddleware(async (to) => {
// logic to determine whether the logged-in user should have access to this page
return abortNavigation()
}
page.vue
definePageMeta({
middleware: ["sidebase-auth", "custom-middleware"]
})
Describe the bug
I need to use the object representation of globalAppMiddleware, as I need to add the default callback URL on login.
I also need some custom middleware that checks to see whether the logged-in user should have access to the page. If they don't, I want to abort the navigation and show an error page.
If I set globalAppMiddleware to false, it all works as expected.
But if I use the object representation, the sidebase-auth middleware sometimes returns "unauthenticated" as the user's status and that causes the user to be redirected to the login page before the custom middleware is able to abort and show the error. So the logged-in user is redirected to the login page.
Additional context
No response
Logs
etienne-bondot
Metadata
Metadata
Assignees
Labels
bugA bug that needs to be resolvedA bug that needs to be resolvedpendingAn issue waiting for triageAn issue waiting for triage