Custom callbackUrl within (custom) provider config not set #4651
Replies: 5 comments 1 reply
-
NextAuth.js expects one callback URL format for all OAuth providers, see: https://next-auth.js.org/configuration/providers/oauth#how-to
I expect adding |
Beta Was this translation helpful? Give feedback.
-
Hi @ThangHuuVu thanks for engaging in this issue. What do you think about the small quick fix? |
Beta Was this translation helpful? Give feedback.
-
@StefanBoehmeSBB @frankfoster could you use the redirect callback in this case? |
Beta Was this translation helpful? Give feedback.
-
@ThangHuuVu – What is the best practice for passing a tunneled origin (e.g. |
Beta Was this translation helpful? Give feedback.
-
Hi, is there any way I can custom the redirect URL when there is an error in the flow of signing in when using Custom OAuth Provider |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Environment
System:
OS: Windows 10 10.0.19042
CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz
Memory: 9.92 GB / 16.00 GB
Binaries:
Node: 16.14.2 - ~\AppData\Local\Volta\tools\image\node\16.14.2\node.EXE
Yarn: 1.22.18 - ~\AppData\Local\Volta\tools\image\yarn\1.22.18\bin\yarn.CMD
npm: 8.5.0 - ~\AppData\Local\Volta\tools\image\node\16.14.2\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.39)
Internet Explorer: 11.0.19041.1566
npmPackages:
next: ^12.1.5 => 12.1.5
next-auth: ^4.3.3 => 4.3.3
Reproduction URL
unfortunately the code is not public
Describe the issue
Description
Hi there, we are using next-auth with a custom provider (see config below) on a custom node server (like so: #531 (comment)) in order to use next-auth on nextjs static generated pages (SSG). Unfortunately we have to use a custom callback URL pattern in order to get this running which is not working properly. What we tried so far is setting the custom URL as callbackUrl parameter (within the provider config) and handling the redirect stuff (custom callback URL <-> /api/auth/*) on our node server.
Provider config:
Server.ts (only relevant part)
Error message
After filling out user credentials the generated code verifier and challenge should be validated. But in this case the callbackURL is not the configured one.
The (quick) fix
Setting the callbackURL within the provider config is not working. What I figured out so far is: moving method parameter '...userOptions' to 3rd place within the following next-auth code snippet will keep the configured callbackURL instead of overriding it.
next-auth/packages/next-auth/src/core/lib/providers.ts
Lines 25 to 29 in 2838dd7
How to reproduce
Expected behavior
Correct (configured) callbackURL is added before triggering /api/auth/callback/<idp_id> in order to validate code verifier and challenge. Keep mind that we have to use a certain callbackURL to meet the IDP specification.
Beta Was this translation helpful? Give feedback.
All reactions