Skip to content

SvelteKit: only modify basePath in SvelteKitAuth cause incorrect URL #11584

@alissa-tung

Description

@alissa-tung

Environment

  System:
    OS: macOS 14.5
    CPU: (12) arm64 Apple M2 Max
    Memory: 48.61 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.3.0 - /nix/store/cpqfn567chsy7mslcfwnijsn6mq82lcq-nodejs-22.3.0/bin/node
    npm: 10.8.1 - /nix/store/cpqfn567chsy7mslcfwnijsn6mq82lcq-nodejs-22.3.0/bin/npm
    pnpm: 9.4.0 - /nix/store/9l6vfmlmfj1fm6bh3i41k9sd59xhkdci-pnpm-9.4.0/bin/pnpm
  Browsers:
    Chrome: 127.0.6533.100
    Safari: 17.5
  npmPackages:
    @auth/sveltekit: ^1.4.2 => 1.4.2

Reproduction URL

https://github.com/alissa-tung/bug-08-12

Describe the issue

the callback in OAuth app is

http://localhost:3000/api/auth/callback/github
  1. every login made redirection to /api/auth/callback/github, but /api/auth/callback/github is always not found, and the URL says redirect_uri_mismatch in search parameters
  2. there is nothing under /api/auth, but /auth/ and /auth/login did has response
  3. if OAuth is configured with http://localhost:3000/auth/callback/github, and remove the basePath, everything is okay

How to reproduce

  1. clone this repo
  2. make an OAuth app with http://localhost:3000/api/auth/callback/github
  3. pnpm dev --port 3000
  4. try login

Expected behavior

path under /api/auth should not be no found when basePath is configured, and anything /auth should be not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions