nextauthjs / nextauthjs/next-auth

SvelteKit: prefix not supported in @auth/sveltekit/client

Open
#6,980 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Environment

System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Max
Memory: 7.74 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm

Reproduction URL

https://github.com/markjaquith/sveltekit-auth-prefix-bug

Describe the issue

prefix is not fully supported. The client code from @auth/sveltekit/client for signIn and signOut have the prefix hardcoded as /auth, and thus do not work on a site where a prefix is configured.

How to reproduce

Set a prefix:

SvelteKitAuth({
		providers: [GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET })],
		prefix: '/prefix/auth',
	})

Attempt to log in using logIn from @auth/sveltekit/client. See that the browser is attempting to communicate with /auth/csrf which does not exist — should be /prefix/auth/csrf

Manually log in by going to /prefix/auth/signin.

Attempt to log out using logOut from @auth/sveltekit/client. See that the browser is attempting to communicate with /auth/csrf which does not exist — should be /prefix/auth/csrf

Expected behavior

prefix should be fully supported.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @auth/sveltekit/client implementations of signIn and signOut, then reproduce the issue using the linked sveltekit-auth-prefix-bug project with prefix set to /prefix/auth. Trace the requests to the CSRF endpoint and confirm that both client operations use the configured prefix rather than /auth.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.