next-auth: V5 `signin()` throws error when using `redirect: false`

Provider type

Email

Environment

System: OS: macOS 14.1.1 CPU: (8) arm64 Apple M1 Pro Memory: 872.53 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node npm: 10.2.4 - ~/.nvm/versions/node/v18.18.2/bin/npm bun: 1.0.14 - ~/.bun/bin/bun Watchman: 2023.11.20.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 119.0.6045.199 Safari: 17.1

Reproduction URL

https://github.com/nextauthjs/next-auth-example

Describe the issue

In "next-auth": "5.0.0-beta.4" the signIn() with redirect: false throws the following error on the client side:

Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid base URL
    at signIn (webpack-internal:///(:3000/en/auth/app-pages-browser)/../../node_modules/next-auth/react.js:172:19)

How to reproduce

Install:

"next-auth": "5.0.0-beta.4"

Run:

const authResponse = await signIn("email", {
      email: data.email,
      redirect: false
})

Expected behavior

Should not throw error

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 30
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Same issue here with credentials provider…

I’ll unsubscribe myself from this thread but can we please just thumbs-up the issue or PR instead of commenting “same”

Would also like to get a new beta release ASAP for next-auth. Currently waiting for this one, since patching it out locally is quite tedious…

i have encounter same issue… any update on this?

I managed to solve the issue. Simply export the signIn method from the NextAuth class and use it in a server action. Something like this:

image image

That’s not solving the issue but changing the environment (client --> server)…

Same issue! When will this make it to the next version?

Same issue 👍

beta5 includes the patch

PR ^ contains fix for this issue.