Skip to content

keycloak sso redirect show 404 #5045

@zwmyxzs

Description

@zwmyxzs

Describe the bug

I overridden the default theme to implement Keycloak SSO, which worked perfectly in version 2.0.0-alpha.1. After a successful Keycloak login, it would redirect back to my documentation page. However, in version 2.0.0-alpha.2, the redirected page shows VitePress's default 404 page. I need to delete the extra parameters in the URL, and sometimes even open a new tab, to display the documentation normally.
I tried removing the parameters from the returned URL: http://localhost:5173/docs/public/kunlun-kie/#state=1f134705-e629-43c0-be3d-c1aa651819f5&session_state=5b5fcf40-7646-48a0-907b-ce7f3fff1890&iss=https%3A%2F%2Fkunlun.shijicloud.com%2Fauth%2Frealms%2FKunlun-DevOps&code=9c33f8e6-6933-437f-90d5-8fbf318ed92d.5b5fcf40-7646-48a0-907b-ce7f3fff1890.ccec98eb-9264-416a-87f2-3f61c842e819. But I couldn't find a pattern—it doesn't seem related to the length. For example, if I delete the entire code parameter, I can access the page normally.

Reproduction

  1. Implement SSO. I have customized the Keycloak SSO implementation logic in the onBeforeRouteChange event.
  2. After logging in with Keycloak, the system will redirect back to the current document page, resulting in a 404 error.

Expected behavior

Display a valid page

System Info

  System:
    OS: Windows 11 10.0.26200
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 13.46 GB / 31.73 GB
  Binaries:
    Node: 22.12.0 - D:\app\scoop\apps\nodejs-lts\current\node.EXE
    npm: 10.9.0 - D:\app\scoop\apps\nodejs-lts\current\npm.CMD
    pnpm: 10.21.0 - D:\app\scoop\shims\pnpm.EXE
  Browsers:
    Chrome: 142.0.7444.176
    Edge: Chromium (140.0.3485.66)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    vitepress: 2.0.0-alpha.2 => 2.0.0-alpha.2

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions