Auth-module: BUG - Redirect to / in firefox with watchLoggedIn true at any non index

Created on 3 Mar 2018  路  19Comments  路  Source: nuxt-community/auth-module

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)
need info need repro

All 19 comments

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.

@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

@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 ? 馃憤

@breakingrobot Cant check in 4.0 because of https://nuxtjs.cmty.io/nuxt-community/auth-module/issues/c83

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

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

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

@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.

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

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

@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

Your build error seems to report the wrong path:

Error: Cannot find module 'C:DevPycharmProjectsrasimplefrontra-front-simple-nuapollo'

Shouldn't it be:

'C:DevPycharmProjectsrasimplefrontra-front-simple-nuapolloauthstrategy'

Going to investigate why the resolution gave the wrong path.

@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

@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.

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

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

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;
}

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nilskoppelmann picture nilskoppelmann  路  3Comments

dasisyouyu picture dasisyouyu  路  3Comments

amjadkhan896 picture amjadkhan896  路  3Comments

weijinnx picture weijinnx  路  3Comments

pi0 picture pi0  路  3Comments