Skip to content

Same config with global and local middleware have different results #1055

@mrleblanc101

Description

@mrleblanc101

Environment


  • Operating System: Darwin
  • Node Version: v20.19.2
  • Nuxt Version: 4.1.1
  • CLI Version: 3.28.0
  • Nitro Version: 2.12.5
  • Package Manager: pnpm@10.14.0
  • Builder: -
  • User Config: compatibilityDate, devtools, modules, css, runtimeConfig, fonts, auth, i18n, vite
  • Runtime Modules: @nuxt/eslint@1.9.0, @nuxt/fonts@0.11.4, @nuxtjs/i18n@10.0.6, @sidebase/nuxt-auth@1.0.2
  • Build Modules: -

Reproduction

.

Describe the bug

Hi,
I've been trying to implement this plugin with the Keycloak provider, but I'm facing some weird issues.
So, I use a custom login screen like so:

Image

When I click the login button, I'm properly redirected to Keycloak:

Image

Once connected, I'm properly redirected to my app main page (currently empty):

Image

But if I try to go to my app main page without being logged-in, I get redirected to this page, but only if I use the globalAppMiddleware like so:

// nuxt.config.js { ... auth: { baseURL: 'http://localhost:3000/api/auth', globalAppMiddleware: true, disableInternalRouting: true, provider: { type: 'authjs', trustHost: false, addDefaultCallbackUrl: true, }, }, ... } // dashboard.vue definePageMeta({ auth: { unauthenticatedOnly: false, navigateUnauthenticatedTo: '/', }, });
Image

I don't want the pre-made login page, but I can't find anywhere in the doc how to disable it completely.

If I disable the globalMiddleware and add middleware: ['sidebase-auth'] like so, it works properly.

// nuxt.config.js { ... auth: { baseURL: 'http://localhost:3000/api/auth', globalAppMiddleware: false, disableInternalRouting: true, provider: { type: 'authjs', trustHost: false, addDefaultCallbackUrl: true, }, }, ... } // dashboard.vue definePageMeta({ middleware: 'sidebase-auth', auth: { unauthenticatedOnly: false, navigateUnauthenticatedTo: '/', }, });

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug that needs to be resolvedquestionA question about NuxtAuth

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions