Skip to content

Auth redirect URLs that already have a query string get a second '?' (status parameter lost) #391

Closed

Description

@breken-ai

What happens

The email verification, password reset and magic-link landing routes add their result to the configured redirect URL with a hard-coded ?:

  • packages/modelence/src/auth/verification.ts:123 ${emailVerifiedRedirectUrl}?status=verified
  • packages/modelence/src/auth/verification.ts:147 ${emailVerifiedRedirectUrl}?status=error&message=...
  • packages/modelence/src/auth/resetPassword.ts:198 ${resetPasswordUrl}?status=error&message=...
  • packages/modelence/src/auth/magicLink.ts:285 ${magicLinkPageUrl}?status=error&message=...

If the configured URL already has a query string, for example https://app.example.com/welcome?source=email, the user is redirected to

https://app.example.com/welcome?source=email?status=verified

The app then reads status as missing, and source becomes email?status=verified.

Expected

https://app.example.com/welcome?source=email&status=verified, so both parameters survive.

Steps to reproduce

  1. Set the email-verified redirect URL (or the reset-password / magic-link page URL) to a URL with a query string, e.g. https://app.example.com/welcome?source=email.
  2. Open a verification link, or an invalid or expired reset or magic link to hit the error branch.
  3. The Location header contains two ?, and new URL(location).searchParams.get('status') is null.

Version: modelence 0.26.0 (main @ 4440162).

Proposed change

A small appendQuery(url, query) helper that joins with & when the URL already contains ?. It would be used at the four call sites above. URLs without a query, including hash-router URLs, would redirect exactly as they do today. I have a branch with the helper and 4 regression tests in the existing verification / resetPassword / magicLink vitest suites. The tests call the real handlers and parse the redirect with URL. All 4 fail on main (expected 'email?status=error' to be 'email') and pass with the change, and the rest of the auth suite still passes (547/547). Branch: https://github.com/breken-ai/modelence/tree/fix/auth-redirect-query-string

CONTRIBUTING asks for an issue first for auth runtime changes, so I'm opening this first. If this approach works for you, I'll open the PR.

Activity

  1. added a commit that references this issue on Oct 14, 2026
    250cd10
  2. added a commit that references this issue on Oct 27, 2026
    afcfe7a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions