Skip to content

bug: history.replaceState drops existing query params and hash after OAuth callback #15

Description

@perry-the-pr-reviewer

Bug

openrouter-oauth/SKILL.md line 77 recommends this URL cleanup after the OAuth callback:

history.replaceState({}, "", location.pathname)

location.pathname strips everything after the path — including existing query params and the hash fragment. This breaks:

  • SPA hash routing (e.g. /#/dashboard becomes /)
  • Any other query params the app had before the OAuth redirect
  • Apps using ? params for state management

Fix

Delete only the code param and preserve everything else:

const u = new URL(location.href);
u.searchParams.delete("code");
u.searchParams.delete("state"); // if used
history.replaceState({}, "", u.toString());

Reviewed by Perry

Activity

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