Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration for home redirect confusing: forces redirect to that page #1010

Open
drocha87 opened this issue Jan 18, 2021 · 2 comments
Open
Labels

Comments

@drocha87
Copy link

"dependencies": {
    "@nuxtjs/auth-next": "^5.0.0-1610809099.bcf293f",
    "@nuxtjs/axios": "^5.12.5",
}

I'm using local auth strategy with Bearer token.

  auth: {
    redirect: {
      login: '/login',
      logout: '/login',
      callback: '/login',
      home: '/',
    },

    strategies: {
      local: {
        token: {
          property: 'accessToken',
          required: true,
          // type: 'Bearer',
        },

        user: {
          property: false,
          // autoFetch: true,
        },

        endpoints: {
          login: { url: '/login', method: 'post' },
          logout: { url: '/users/logout', method: 'post' },
          user: { url: '/users', method: 'get' },
        },
      },
    },
  },

After a successful login, I'm redirected to / as expected and defined in home, but suppose that I'm in a route like /keys and my token expired, which means that I'll be redirected to /login as expected, but I expect that after another successful login, this time I'll be redirected to /keys.

I was doing this (@nuxtjs/auth v4) by myself using a plugin like this one, which looks pretty much the same as here in this core function.

So I'm wondering if I can do that without this plugin using just the new (@nuxtjs/auth-next v5)?

I removed the plugin, set many properties (rewriteRedirects, fullPath), but I couldn't find a way to it to work.

@drocha87
Copy link
Author

drocha87 commented Jan 18, 2021

Ok, as usual after 1 hour I figured out that the only thing I need to do was to comment/remove home: '/' in redirect.

home: User will be redirected to this path after login. (rewriteRedirects will rewrite this path)

It was not clear to me that if I had home set in configuration it will disable the rewriteRedirects to work properly. As English is not my first language, maybe it was my fault to understand, or maybe the documentation is not clear enough about that, and so we need to improve it.

@bmulholland bmulholland changed the title [@nuxtjs/auth-next] login with redirect to previous route. Configuration for home redirect confusing: forces redirect to that page Jan 20, 2022
@LangRizkie
Copy link

LangRizkie commented Apr 20, 2022

Sorry, is this still maintained? I've tried to remove home but it still redirected to the homepage instead previous route

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants