Skip to content

Regression in 52.16.0 (#2562): getSlidePath double-prefixes BASE_URL → navigation 404 on subdirectory (--base) deploys #2635

Description

@opariffazman

Describe the bug

Since v52.16.0, a deck built for a sub-directory (slidev build --base /sub/) 404s when navigating between slides. Clicking/pressing to the next slide produces a URL with the base doubled, e.g. landing on /<base>/1 and pressing → goes to /<base>/<base>/2, which matches no route and renders Slidev's own "404 — Page //2 not found".

This is a regression introduced by #2562 ("use BASE_URL in getSlidePath for monorepo sub-directory deployments"), which is the only change shipped in 52.16.0 touching packages/client/logic/slides.ts.

Root cause

getSlidePath now returns a base-prefixed path:

// 52.16.0 (after #2562) — packages/client/logic/slides.ts
return `${import.meta.env.BASE_URL}${path}`   // e.g. "/sub/2"
// 52.15.2 (before #2562) — returned a base-LESS path
return presenter ? `/presenter/${no}` : `/${no}`   // e.g. "/2"

But the router history is already created with the base:

// setup/main.ts
createWebHistory(import.meta.env.BASE_URL)   // base = "/sub/"

…and navigation pushes the getSlidePath value as a route path:

// composables/useNav.ts (go)
router.push({ path: getSlidePath(no, isPresenter.value, ...) })

So with --base /sub/, router.push({ path: "/sub/2" }) runs through a history whose base is /sub/, and the base is prepended again → URL /sub/sub/2, route /sub/2 → no match (routes are /:no) → 404. Affects both routerMode: history and hash (in hash mode it's /sub/#/sub/2).

Reproduction

  1. Any deck. Set build to slidev build --base /sub/ --out dist/sub.
  2. Serve dist with any static server so the deck is at http://localhost:PORT/sub/.
  3. Open /sub/, press → (next slide).

Expected: /sub/2 (slide 2).
Actual (52.16.0): /sub/sub/2 → Slidev 404 page. Works correctly on 52.15.2.

Verified with a plain static file server (no edge/host rewrites involved), so this is purely client-side routing.

Reproduction (link)

Minimal: any slidev build --base /sub/ output served at /sub/. Happy to provide a repo if helpful.

System Info

@slidev/cli: 52.16.0 (broken) vs 52.15.2 (works)
routerMode: history (default) and hash both affected

Suggested fix

Either have getSlidePath return a base-less path again (and rely on the history base), or strip the base before router.push in useNav, so the base is applied exactly once.

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