Angular SPA loginWithRedirect() leads to undefined

Hi everyone,

I really can’t tell why but after i click the Login Button on my Angular App, i wont get redirected to Auth0 Login. Instead I get:

https://undefined/authorize?redirect_uri=http://localhost:4200&scope=

It always leads me to undefined…

This is my env file:

export const environment = {
    production: false,
    hmr       : false,
    auth: {
        domain: 'dev-**********.eu.auth0.com',
        clientId: 'RHB78**************rdvXN',
        redirectUri: window.location.origin + '/callback',
        audience:'test.***********.online',
      },
      dev: {
        serverUrl:"http://localhost:3000",
      },
};

This is my app.module import:

   AuthModule.forRoot({
        ...env.auth,
        httpInterceptor: {
          allowedList: [`${env.dev.serverUrl}/users`],
        },
      }),

Does anyone have an idea why it doesnt pick up the correct domain? I tried so much and I am kind of clueless right now. Looking forward for some advice :slight_smile:

Cheers, Merlin

Edit:
The same happens when i put authguard infront of my index page e.g. I get the same url.
There are no spelling mistakes in the variables

I moved the AuthModule right under AppRoutingModule and that worked for me :slight_smile:

1 Like

Thanks for sharing that with the rest of community!