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
- Any deck. Set
build to slidev build --base /sub/ --out dist/sub.
- Serve
dist with any static server so the deck is at http://localhost:PORT/sub/.
- 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.
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>/1and 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
getSlidePathnow returns a base-prefixed path:But the router history is already created with the base:
…and navigation pushes the
getSlidePathvalue as a route path: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 bothrouterMode: historyandhash(in hash mode it's/sub/#/sub/2).Reproduction
buildtoslidev build --base /sub/ --out dist/sub.distwith any static server so the deck is athttp://localhost:PORT/sub/./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
Suggested fix
Either have
getSlidePathreturn a base-less path again (and rely on the history base), or strip the base beforerouter.pushinuseNav, so the base is applied exactly once.