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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions