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

BUG - Redirect to / in firefox with watchLoggedIn true at any non index #80

Closed
aldarund opened this issue Mar 3, 2018 · 19 comments
Closed

Comments

@aldarund
Copy link
Member

aldarund commented Mar 3, 2018

With default watchLoggedIn: true in FF every request to any url will be redirected to /.
It only happens on first load, clicking links within app work fine. But on first load you will be just redirected to / . Even with user logged in.
Chrome works fine without redirect
It happens without any use of auth middleware ( so there shouldnt be any redirect at all).
mode - spa.

This question is available on Nuxt.js community (#c59)
@aldarund aldarund changed the title Redirect to / in firefox with watchLoggedIn true BUG - Redirect to / in firefox with watchLoggedIn true at any non index Mar 3, 2018
@aldarund
Copy link
Member Author

Same with dev branch with strategies, although watchLoggedIn false doesnt work anymore and neither work setting

redirect: {
      logout: false,
      login: false,
      callback: false
    },

Chrome still fine and problem still only in ff

Disabling nuxt/auth module fixes redirect issue.

@aldarund
Copy link
Member Author

@breakingrobot Figured out a bit .
redirect: false in options fixes the issue.
The redirect itself caused by trigger of autoRedirect function
https://github.com/nuxt-community/auth-module/blob/dev/lib/auth/auth.js#L35

@breakingrobot
Copy link
Contributor

breakingrobot commented Apr 3, 2018

@aldarund Hi, thanks for your bug report !

I would like to know if this issue persist with the stable release of 4.0, could you confirm this ? 👍

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot
Copy link
Contributor

@aldarund Could you try using the dev branch please, I merged fixes recently 👍

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot second issue with scheme/local gone. But still have first issue with using custom scheme

@breakingrobot
Copy link
Contributor

@aldarund Could you post your custom scheme as a Gist or link to a reproduction way :) ?

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot https://gist.github.com/aldarund/e6f030287057dc056732b1875eb11297
nuxt config:

auth: {
    strategies: {
       apollo: {
         _scheme: '~/apollo/auth/strategy.js'
      }
    },
    redirect: false
  },

I dont think scheme itself relevant. It fails on build on resolveProvider it doesnt even touch scheme as far as i understand.

@breakingrobot
Copy link
Contributor

breakingrobot commented Apr 3, 2018

@aldarund Can you paste the build error stack on resolveProvider 👍 ?

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot
Copy link
Contributor

breakingrobot commented Apr 3, 2018

@aldarund I assume C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu\apollo does exist, is that right ?

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot yes. https://i.imgur.com/IRgFGoH.png

 Directory of C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu\apollo\auth

03.04.2018  15:36    <DIR>          .
03.04.2018  15:36    <DIR>          ..
03.04.2018  15:36             1 034 strategy.js

@breakingrobot
Copy link
Contributor

Your build error seems to report the wrong path:

Error: Cannot find module 'C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu\apollo'

Shouldn't it be:

'C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu\apollo\auth\strategy'

Going to investigate why the resolution gave the wrong path.

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot As i understand it doesnt even touch _scheme ( resolveScheme doesnt trigger for custom scheme ) property but rather try to find a provider from a strategy name, so hence it tries apollo dir.
Heh, found something interesting. If i change strategy name to following:

    strategies: {
      xxxx: {
        _scheme: '~/apollo/auth/strategy.js'
      }

All compiles fine. So it seems to be confused by existence of directory with same name as a strategy and tries to load provider from it or smth like this

@aldarund
Copy link
Member Author

aldarund commented Apr 3, 2018

@breakingrobot i have tested with renamed folder to workaround resolve issue. Original issue still persist. It happens only in SPA mode and only in FF ( maybe in some other browsers but i tested only in chrome and FF, chrome fine - FF redirect). In server mode works fine.

@breakingrobot
Copy link
Contributor

@aldarund We know why the issue happens and are going to fix it with @pi0 ;)

@chuckcharles
Copy link

I have this same issue even after 4.3.0. Only in FF.

@jon-mckinney
Copy link

jon-mckinney commented May 15, 2018

Same here, still seeing the same issue after updating to 4.3.0. In Firefox, the this.ctx.from value is populated on subsequent page loads, prohibiting the early return condition from triggering properly in the implemented fix.

// Disable redirect on refresh / direct load of a page.
if (loggedIn && !_this.ctx.from) {
  return;
}

@pi0
Copy link
Member

pi0 commented May 21, 2018

This problem should finally be fixed with 4.5.0. watchLoggedIn was called too early before the strategy is ready. Also watchLoggedIn option support added back so we can entirely disable it.

https://github.com/nuxt-community/auth-module/releases/tag/v4.5.0

@pi0 pi0 closed this as completed May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants