Closed aakash14goplani closed 7 months ago
cc: @balazsorban44 @ThangHuuVu @ndom91
Hey @aakash14goplani so first of all, thanks for the reproduction!
However, I'm having trouble getting it to reproduce the error, as the reproduction doesn't include any basePath
configuration. Not in the svelte.config
nor in the Auth.js config.
Just in general, you shuold set the basePath
in the auth config as well (key basePath
). You can drop the NEXTAUTH_URL
/ AUTH_URL
env var as well.
Can you give that a shot?
Okay so i was able to get everything to work in 0.5.0
and not in 0.11.0
. With the error message Not found: "/aakash/auth/signout"
.
To get your repro to work in 0.5.0
required some changes though, for future reference:
basePath
to Auth.js config and sveltekit configNEXTAUTH_URL
from .envevent.url.pathname.includes('/aakash') ||
to the hooks.server.ts
redirect logic (line 12
)That setup leads to all Auth.js routes to be 404
-ed, i.e. /aakash/auth/session
, /aakash/auth/signout
, etc.
@aakash14goplani looks like this small change (https://github.com/nextauthjs/next-auth/pull/9889) was able to get it working in 0.11.0
in the following situations:
basePath
set in Auth.js config + no base
set in svelte.config
and no AUTH_URL
set.basePath
set in Auth.js config + no base
set in svelte.config
, but AUTH_URL
is set.basePath
set in Auth.js config + base
set in svelte.config
and no AUTH_URL
basePath
set in Auth.js config + base
set in svelte.config
and AUTH_URL
is set.Give it a shot and let me know if it helps your case as well :+1:
Hello @ndom91
Thanks for quick response. I was able to fix it by adding basePath
property in SvelteKitAuthConfig
. It's value must be "/my-base-url/auth". Also removed NEXTAUTH_URL
from environment variables.
Feedback - I have been an early user of SvelteKitAuth. I have been using it for over an year now, starting with v0.3 - till date. All the releases are making this package more useful (and thanks to all of your combined efforts for that) but this version literally broke the flow. Please think about it as I maybe the first one to notice and I expect streams of similar issues will be followed as "basePath" was nowhere in picture and suddenly it is mandatory with recent change!
Thanks Again!
@aakash14goplani first of all thanks for being an early adopter! Your feedback and issues like these are essential for us to reach stability!
The idea is that it won't be required to set basePath
by default! Hence it was not communicated. See @ndom91's PR #9889 (merging/releasing as I write this).
Environment
Reproduction URL
https://github.com/aakash14goplani/sveltekit-auth-session-token/tree/new-version-test
Describe the issue
signIn
) and server initiated login (via fetch api)@auth/sveltekit
i.e. 0.11.0, prior to this version, everything works like charmHow to reproduce
signIn
, check network tab, "csrf" call gets failedLogin with server flow using below code but csrf call gets failed
Expected behavior
User should be able to login when base path is configured in SvelteKit app