Skip to content

Troubleshooting

Alisha Evans edited this page May 21, 2024 · 4 revisions

TypeError [ERR_INVALID_URL]: Invalid URL

INFO

FULL ERROR

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:400:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:645:5)
    at parseUrl (.../node_modules/next-auth/utils/parse-url.js:17:16)
    ...
    at Module.require (node:internal/modules/cjs/loader:1105:19) {
  input: '',
  code: 'ERR_INVALID_URL',
  page: '/'
}

SOLUTION

Correct the value of NEXTAUTH_URL in .env.development. (Reference .env.development.example for details) If this is the initial setup and you don't know that value yet, comment the variable out.

Outgoing request timed out after XXXms

INFO

FULL ERROR

[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error outgoing request timed out after 3500ms {
  error: RPError: outgoing request timed out after 3500ms
      at REPO-PATH/node_modules/openid-client/lib/helpers/request.js:137:13
      at async Client.grant (REPO-PATH/node_modules/openid-client/lib/client.js:1316:22)
      at async Client.oauthCallback (REPO-PATH/node_modules/openid-client/lib/client.js:603:24)
      at async oAuthCallback (REPO-PATH/node_modules/next-auth/core/lib/oauth/callback.js:111:16)
      at async Object.callback (REPO-PATH/node_modules/next-auth/core/routes/callback.js:52:11)
      at async AuthHandler (REPO-PATH/node_modules/next-auth/core/index.js:201:28)
      at async NextAuthHandler (REPO-PATH/node_modules/next-auth/next/index.js:24:19)
      at async REPO-PATH/node_modules/next-auth/next/index.js:60:32
      at async Object.apiResolver (REPO-PATH/node_modules/next/dist/server/api-utils/node.js:366:9)
      at async DevServer.runApi (REPO-PATH/node_modules/next/dist/server/next-server.js:481:9) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: NEXT_PUBLIC_PROVIDER_NAME,
  message: 'outgoing request timed out after 3500ms'
}

SOLUTION

Add the below to the providers object in "[...nextauth].js". e.g., after the "token" property. This is mainly necessary when running the local webstore against a local instance of rx.

httpOptions: {
  timeout: 100000,
},

Unable to get local issuer certificate

INFO

FULL ERROR

[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error unable to get local issuer certificate {
  error: Error: unable to get local issuer certificate
      at TLSSocket.onConnectSecure (node:_tls_wrap:1545:34)
      at TLSSocket.emit (node:events:513:28)
      at TLSSocket.emit (node:domain:489:12)
      at TLSSocket._finishInit (node:_tls_wrap:959:8)
      at ssl.onhandshakedone (node:_tls_wrap:743:12) {
    name: 'OAuthCallbackError',
    code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
  },
  providerId: NEXT_PUBLIC_PROVIDER_NAME,
  message: 'unable to get local issuer certificate'
}

SOLUTION

  • Stop the server
  • Run export NODE_TLS_REJECT_UNAUTHORIZED=0
  • Restart the server

The above change will result in the following warning: "Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification."