auth0 / auth0-vue

Auth0 authentication SDK for Vue.js apps
Other
140 stars 27 forks source link

Nuxt's middleware cannnot handle the page redirection. #427

Closed Fukao0129 closed 1 month ago

Fukao0129 commented 1 month ago

Checklist

Description

The users are redirected to / after logging in. I'm sure this is a correct behavior because I've checked this documentation.

However, Nuxt's middleware seems to be unable to properly handle this page redirection.

In a scenario where a user is redirected to /callback upon login and then subsequently to /, both the 'to' and 'from' parameters within the middleware are incorrectly set to /callback.

The 'to' should be /.

This leads to a catastrophic situation where many logics using middleware cannot be implemented.

Reproduction

  1. Setup the SDK in plugins
    
    import { createAuth0 } from "@auth0/auth0-vue";

export default defineNuxtPlugin((nuxtApp) => { const runtimeConfig = useRuntimeConfig(); const auth0 = createAuth0({ domain: runtimeConfig.public.auth0Domain, clientId: runtimeConfig.public.auth0ClientId, authorizationParams: { redirect_uri: https://${window.location.hostname}:3000/callback/, scope: "openid profile email", audience: runtimeConfig.public.auth0Audience, }, });

nuxtApp.vueApp.use(auth0); });


2. Login with `auth0.loginWithRedirect();`

3. Check the middleware

export default defineNuxtRouteMiddleware((to, from) => { console.log(to.path); console.log(from.path); });



### Additional context

_No response_

### auth0-vue version

2.3.3

### Vue version

Vue 3.5.10 / Nuxt 3.13.0

### Which browsers have you tested in?

Chrome, Edge, Firefox