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

Redirect to login page after page reload in "refresh" provider #744

Open
devknight216 opened this issue Apr 24, 2024 · 5 comments
Open

Redirect to login page after page reload in "refresh" provider #744

devknight216 opened this issue Apr 24, 2024 · 5 comments
Labels
bug A bug that needs to be resolved help-needed Action needed: The help of the community would be appreciated p3 Minor issue

Comments

@devknight216
Copy link

devknight216 commented Apr 24, 2024

Environment

OS: Windows 11
Browser: Chrome(the only one I work)

Reproduction

My nuxt.config.ts configuration

auth: {
    baseURL: process.env.NUXT_PUBLIC_AUTH_URL,
    provider: {
      type: 'refresh',
      pages: {
        login: '/login'
      },
      endpoints: {
        signIn: {
          path: '/login',
          method: 'post',
        },
        signOut: {
          path: '/logout',
          method: 'post',
        },
        signUp: {
          path: '/register',
          method: 'post',
        },
        getSession: {
          path: '/session',
          method: 'get',
        },
        refresh: {
          path: '/refresh',
          method: 'post',
        }
      },
      token: { signInResponseTokenPointer: '/access_token' },
      refreshToken: { signInResponseRefreshTokenPointer: '/refresh_token' },
    },
  },

Describe the bug

It works well unless I reload the page. But after reloading the page at some point after successful login, it redirects to the login page. I analyzed the localstorage, sessionstorage, cookies of dev tools in the browser, but I couldn't find accessstoken saved in any of those areas. I only found refreshToken saved in the cookies. As far as I know, accessToken should be saved somewhere in the browser to put to the header with axios intercepter. As auth works fine unless reload page and it's not working after page reload, I assume it may be saved to memory. I couldn't find it in other areas as I stated.
If my guess is wrong, please let me know where I can find accessToken after login and how to fix this issue.

Additional context

No response

Logs

No response

@devknight216 devknight216 added bug A bug that needs to be resolved pending labels Apr 24, 2024
@dimitrileduc
Copy link

Hello, are there any updates on this? I'm experiencing the same issue.
It works fine with 'local' type, but doesn't work with 'type: 'refresh''. It seems there is no access token stored.

@zoey-kaiser zoey-kaiser added needs-reproduction Action needed: A valid reproduction of the issue needs to be added and removed pending labels May 10, 2024
Copy link

Hello 👋

Please provide a reproduction for this issue 🙏

How can I create a reproduction?

Please use one of the following links to reproduce your issue.

Please ensure that the reproduction is as minimal as possible. This will allow us to isolate the issue as best as possible.

Here are some more amazing posts about the importance of reproductions:

@phoenix-ru phoenix-ru added p3 Minor issue help-needed Action needed: The help of the community would be appreciated and removed needs-reproduction Action needed: A valid reproduction of the issue needs to be added labels May 14, 2024
@phoenix-ru
Copy link
Collaborator

Investigation by the community would be highly appreciated, as the team is currently focused on merging long-awaited PRs and preparing for 0.8

@skmd87
Copy link

skmd87 commented May 15, 2024

this issue occured to me, make sure you have both signInResponseRefreshTokenPointer & refreshRequestTokenPointer in refreshToken object:
refreshToken: { signInResponseRefreshTokenPointer: '/refreshToken', refreshRequestTokenPointer: '/refreshToken', cookieName: 'auth.refreshToken', maxAgeInSeconds: 1000 * 60 * 60 * 24, },

@dev-davexoyinbo
Copy link

You can consider using this npm package
https://www.npmjs.com/package/@workmate/nuxt-auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved help-needed Action needed: The help of the community would be appreciated p3 Minor issue
Projects
None yet
Development

No branches or pull requests

6 participants