# 502 error when hitting auth/login

**URL:** <https://community.auth0.com/t/502-error-when-hitting-auth-login/72161>\
**Category:** Get Help\
**Tags:** callback, sso, nextjs, auth0\
**Created:** [October 27, 2021, 12:22pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161 "2021-10-27T12:22:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/keithg/32/12848_2.png) [@keithg](https://community.auth0.com/u/keithg)\
**Post date:** [October 27, 2021, 12:22pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/1 "2021-10-27T12:22:15Z")

</div>

I have a hosted website running nextjs and am using the nextjs-auth0 module for authentication. This was working fine but hitting auth/login (initially through Google SSO) using a particular browser session results in a 502 error. The same exact process works fine in a new window (with a different generated state of course). Any idea of why this is happening?

Using Chrome 95 on Mac OS.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 27, 2021, 5:50pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/3 "2021-10-27T17:50:23Z")

</div>

Hi @keithg,

Welcome to the Auth0 Community!

Can you please provide some more detail? What request is returning the error? You can use Google’s developer tools to see what is happening:

> **[Inspect network activity - Chrome Developers](https://developer.chrome.com/docs/devtools/network/)**
>
> A tutorial on the most popular network-related features in Chrome DevTools.

---

<div class="post-metadata">

**Author:** ![keithg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/keithg/32/12848_2.png) [@keithg](https://community.auth0.com/u/keithg)\
**Post date:** [October 27, 2021, 6:35pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/4 "2021-10-27T18:35:11Z")

</div>

Thank you Dan.

When trying to sign in the Auth0 callback calls my nextjs `/api/auth/callback` api route which executes the callback method in the nextjs-auth0 package. This is returning a 502.

 ![Screenshot 2021-10-27 at 20.09.20 copy](https://global.discourse-cdn.com/auth0/original/3X/2/c/2c3fc98aff7104086edb7a910881a42486b82c1a.png)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 27, 2021, 9:05pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/5 "2021-10-27T21:05:25Z")

</div>

Can you please share a codeblock with the function that is causing this?

---

<div class="post-metadata">

**Author:** ![keithg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/keithg/32/12848_2.png) [@keithg](https://community.auth0.com/u/keithg)\
**Post date:** [October 28, 2021, 1:24am UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/6 "2021-10-28T01:24:51Z")

</div>

It simply performs a call to `handleLoginWindowOpener` function.

```auto
  const handleLoginWindowOpener = async () => {
    window.open('/login/api/auth/logout','_blank');
  }

  // ----------------------------------------------------

  return (
    <header>
      <span className="text-md text-pink">
        <button onClick={handleLoginWindowOpener}>{sessionInfo.user ? 'Click to logout.' : 'Click to login or to create an account.'}</button>
      </span>
      <span className="text-md text-gray">
        {' | '}{hostname} {sessionInfo.token?.expiry ? ` (current login valid till ${timestampToDateString(sessionInfo.token.expiry)})` : ' (logged out)'}
      </span>
    </header>
  )
}

```

Issue happens on one particular instance after attempting to/signing in using Google. There is nothing in the nginx logs either, seems like the call didn’t reach the server.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 28, 2021, 4:06pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/7 "2021-10-28T16:06:09Z")

</div>

The route you are using looks a bit odd, typically we see `/api/auth/logout`, instead of `/login/api/auth/logout`. Is it possible this route is causing the issue?

---

<div class="post-metadata">

**Author:** ![keithg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/keithg/32/12848_2.png) [@keithg](https://community.auth0.com/u/keithg)\
**Post date:** [October 28, 2021, 4:37pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/8 "2021-10-28T16:37:13Z")

</div>

The /login/ route is being captured by nginx and forwarded accordingly (correct route/port). I’ve never encountered any issues apart from this specific instance and it works as expected if opened in a new window.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 28, 2021, 5:12pm UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/9 "2021-10-28T17:12:30Z")

</div>

Can you please DM me a [HAR](https://auth0.com/docs/troubleshoot/guides/generate-har-files) of a failed request?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 2, 2021, 12:56am UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/10 "2021-11-02T00:56:10Z")

</div>

This ended up being an issue with an older version of the nextjs-auth0 SDK. Resolved by upgrading to the latest version.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 17, 2021, 12:57am UTC](https://community.auth0.com/t/502-error-when-hitting-auth-login/72161/11 "2021-11-17T00:57:06Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
