nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 924 forks source link

Setting redirect.callback = false is not supported and throws an error #1762

Open mfrascati opened 2 years ago

mfrascati commented 2 years ago

Version

module: auth-next@^5.0.0-1643791578.532b3d6 nuxt: 2.15.8

Nuxt configuration

mode:

Nuxt configuration

  auth: {
    strategies: {
      google: {
        clientId:
          "xxxx",
        codeChallengeMethod: "",
        responseType: "code",
        redirectUri: frontEndUrl + "/oauth/google",
      },
     },
    redirect: {
      login: "/login",
      logout: false,
      callback: false,
      home: false,
    },
    rewriteRedirects: true,
  },

What is expected?

As mentioned by the docs: Each redirect path can be disabled by setting to false. Also you can disable all redirects by setting redirect to false

What is actually happening?

If I set the callback redirect to false the module still tries to fetch it as it only checks if the whole redirect object is set

async _handleCallback() {
    if (this.$auth.options.redirect && normalizePath(this.$auth.ctx.route.path, this.$auth.ctx) !== normalizePath(this.$auth.options.redirect.callback, this.$auth.ctx)) {
      return;
    }

Then normalizePath gets as first param false and throws an error

image

Not sure why, if I call the method a second time it prepends the false with // and //false becomes an acceptable string param for normalizePath and it works.