# Angular SPA loginWithRedirect() leads to undefined

**URL:** <https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [December 6, 2021, 10:45am UTC](https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304 "2021-12-06T10:45:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Merlin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/merlin/32/33431_2.png) [@Merlin](https://community.auth0.com/u/Merlin)\
**Post date:** [December 6, 2021, 10:45am UTC](https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304/1 "2021-12-06T10:45:36Z")

</div>

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=](https://undefined/authorize?redirect_uri=http://localhost:4200&scope=)…

It always leads me to undefined…

This is my env file:

```auto
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 🙂

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

---

<div class="post-metadata">

**Author:** ![Merlin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/merlin/32/33431_2.png) [@Merlin](https://community.auth0.com/u/Merlin)\
**Post date:** [December 6, 2021, 12:23pm UTC](https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304/2 "2021-12-06T12:23:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 6, 2021, 5:27pm UTC](https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304/3 "2021-12-06T17:27:24Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 7, 2021, 2:31pm UTC](https://community.auth0.com/t/angular-spa-loginwithredirect-leads-to-undefined/74304/4 "2021-12-07T14:31:55Z")

</div>


