nuxt-auth: Invalid Url upgrading to 0.6.2

Environment

  • Operating System: Linux
  • Node Version: v18.15.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.0
  • Package Manager: npm@9.5.0
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

No response

Describe the bug

I’m upgrading from 0.5.0 to 0.6.2

this is my nuxt.config.ts auth: { // @ts-ignore (isEnabled boolean type) //BE CAREFULL, With visual studio debugger isEnabled can't be false, fails... issue opened isEnabled : process.env.NUXT_AUTH_ENABLED=="true", //all environment variables are strings baseURL :http://localhost:3000/api/auth`, // The origin is set to the development origin. Change this when deploying to production by setting origin in this config before build-time or by exporting AUTH_ORIGIN by running export AUTH_ORIGIN=...
// Whether to add a global authentication middleware that will protect all pages without exclusion globalAppMiddleware : false, provider : { type: ‘authjs’ } },`

My NuxtAuthHandler are in : image

The error is: { "url": "/api/auth/callback/credentials", "statusCode": 500, "statusMessage": "", "message": "Invalid URL", "stack": "<pre><span class=\"stack internal\">at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)</span>\n<span class=\"stack internal\">at new NodeError (node:internal/errors:399:5)</span>\n<span class=\"stack internal\">at URL.onParseError (node:internal/url:566:9)</span>\n<span class=\"stack internal\">at new URL (node:internal/url:646:5)</span>\n<span class=\"stack internal\">at Object.redirect (./node_modules/next-auth/core/lib/default-callbacks.js:16:65)</span>\n<span class=\"stack internal\">at createCallbackUrl (./node_modules/next-auth/core/lib/callback-url.js:20:35)</span>\n<span class=\"stack internal\">at init (./node_modules/next-auth/core/init.js:131:48)</span>\n<span class=\"stack internal\">at AuthHandler (./node_modules/next-auth/core/index.js:131:28)</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at <anonymous> (./node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.mjs:88:24)</span>\n<span class=\"stack internal\">at async Object.handler (./node_modules/h3/dist/index.mjs:1675:19)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1885:7)</span></pre>" }

Any idea that whats happend?

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 25 (5 by maintainers)

Most upvoted comments

Looks like I had a similar error

When I tried signIn('google') it redirected me to the login page with invalid url error in the console, although before it was opening google auth page right away

removing line globalAppMiddleware: false

helped me

Hi @agracia-foticos,

As @davidlemaitre suspects, I think that somewhere a url is not being set correctly. Therefore I would recommend the following to try and debug this problem:

  • remove all environment variables relating to auth
  • Remove baseURL from the nuxt.config (in development, NuxtAuth can automatically determine your origin)
  • If this does not work, please hard code baseURL in your nuxt.config to localhost:3000.

I also wanted to remind you that setting baseURL in the nuxt config is for injecting the environment variable at build time and setting it via AUTH_ORIGIN is for injecting it runtime. You do not need to set both, one is enough!

Any notice?

Any solution??