Search code examples
next.jsauth0next-auth

NEXT JS using Auth0 runtime error that disappears after a second


I am using auth0 with NEXT JS. When trying to login or logout , I get this error for like 0.2 s, then I get redirected to the path that I'm supposed to be redirected to,to get authenticated.

Unhandled Runtime Error
Error: Failed to load script: /_next/static/chunks/pages/api/auth/%5B...auth0%5D.js

.next\static\chunks\main.js (83:51) @ HTMLScriptElement.script.onerror

  81 | //    executes when `src` is set.
  82 | script.onload = resolve;
> 83 | script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)))
     |                                           ^
  84 | ;
  85 | // 2. Configure the cross-origin attribute before setting `src` in case the
  86 | //    browser begins to fetch.


Solution

  • So after searching a lot, and not being to find the answer, I got lucky on a hunch. The problem was using Link tags from next/link. I was passing it a URL outside of the scope of the site. Swapping that to a simple a tag did the trick for me