Skip to content

fix: use BASE_URL in getSlidePath for monorepo sub-directory deployments#2562

Open
NgoQuocViet2001 wants to merge 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:ai/trending-test-virtual-module-fix
Open

fix: use BASE_URL in getSlidePath for monorepo sub-directory deployments#2562
NgoQuocViet2001 wants to merge 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:ai/trending-test-virtual-module-fix

Conversation

@NgoQuocViet2001
Copy link
Copy Markdown

Summary

When Slidev is deployed to a sub-directory within a monorepo (e.g., /my_monorepo/my_prez/), the getSlidePath function in packages/client/logic/slides.ts was generating URLs that ignored Vite's base option, resulting in broken navigation to export and presenter pages.

Before: getSlidePath(route, false, false) returned /2 regardless of base path
After: Returns ${import.meta.env.BASE_URL}2 (e.g., /my_monorepo/my_prez/2)

This matches how other parts of Slidev handle base-relative assets (e.g., manualChunks in extendConfig.ts uses import.meta.env.BASE_URL).

Changes

  • packages/client/logic/slides.ts (line 23): Changed hardcoded path prefixes to use import.meta.env.BASE_URL prepended to the path
  • test/utils.test.ts: Added test case that verifies correct path generation with a mocked BASE_URL value

Test Plan

pnpm vitest run test/utils.test.ts

All 8 tests pass including the new getSlidePath with base path test.

Fixes: #2384

When Slidev is deployed to a sub-directory within a monorepo (e.g.,
/my_monorepo/my_prez/), the generated slide URLs were hardcoded to
start with /export/, /presenter/, or /, ignoring Vite's base option.

Now getSlidePath prepends import.meta.env.BASE_URL to the path, matching
how other parts of Slidev handle base-relative assets.

Fixes: slidevjs#2384
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 28, 2026

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 6cf5ecc
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69f0375b2248090008b3b533
😎 Deploy Preview https://deploy-preview-2562--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant