Auth0-spa-js: Angular router, useHash - results in: There are no query params available at window.location.search.

Created on 26 Sep 2019  ·  5Comments  ·  Source: auth0/auth0-spa-js

NOTE: currently using the "@auth0/auth0-spa-js": "^1.2.3" will produce the following error after a successful login, if the angular routes do have useHash: true (so use a # in the route).

Error at callback:
There are no query params available at window.location.search.

Bypass:
Avoid useHash: true in the router

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: false }) ],
  exports: [RouterModule]
})
export class AppRoutingModule { }

Most helpful comment

I have this problem with auth0-spa-ts as well, but adding usehash:false to router does not fix it.

All 5 comments

@hidegh thanks for reporting this. What is the end result of your url? Something like http://myapp.com/#/callback?code=123?

@luisrudge exactly

I have this problem with auth0-spa-ts as well, but adding usehash:false to router does not fix it.

@CloudEntity57 Which version are you testing with?

Same as @CloudEntity57 but it only happens with stupid Safari. The app works fine in Chrome.
Using:

@auth0/auth0-spa-js: ^1.6.5

Was this page helpful?
0 / 5 - 0 ratings