After the user logs in I want to redirect to the original requested url, to achieve this I want to leverage the options prop of the SignIn.svelte component as seen here in the repro.
Run the repro repository and click the sign in button on the index page, notice how it does not redirect to the /test url
This should be an easy fix by correctly reading the callbackUrl from the options, my testing fix looks like this:
Environment
System: OS: macOS 14.2.1 CPU: (10) arm64 Apple M2 Pro Memory: 97.36 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.7.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 10.1.0 - /opt/homebrew/bin/npm Browsers: Chrome: 122.0.6261.69 Safari: 17.2.1
Reproduction URL
https://github.com/kinglouie/authjsrepro2/
Describe the issue
After the user logs in I want to redirect to the original requested url, to achieve this I want to leverage the
options
prop of theSignIn.svelte
component as seen here in the repro.This feature is unfortunately broken at the moment. The
redirectTo
url is successfully transmitted by the hidden form input but the sveltekit specificsignIn
action is buggy in this snippet: https://github.com/nextauthjs/next-auth/blob/fbb8af526b075b9161e0bf7642c9ee730c3212b0/packages/frameworks-sveltekit/src/lib/actions.ts#L22-L28 theoptions
obj does not contain the keyredirectTo
, instead the redirect url is in thecallbackUrl
and also in theredirect
key. Options looks like this when logging it in my repro:How to reproduce
Run the repro repository and click the sign in button on the index page, notice how it does not redirect to the
/test
url This should be an easy fix by correctly reading thecallbackUrl
from the options, my testing fix looks like this: