fix: honor configured base for dev authoring APIs - #393
Conversation
Client /__* fetches now go through a devApiUrl() helper built on import.meta.env.BASE_URL, and server routes are mounted beneath the resolved base (keeping the root mounts for direct probes), so folder mutations, inline editing, notes, comments, assets, and server actions work when OpenSlide is hosted at a subpath. Fixes 1weiho#392 Claude-Session: https://claude.ai/code/session_01Gu3Kz4JQBFc6kKkAfEoXCq
|
@iddogino is attempting to deploy a commit to the open-slide Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughDevelopment API clients now build URLs from ChangesBase-aware development API routing
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/vite/routes/svgl.ts (1)
5-6: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the endpoint-description comments.
These comments describe behavior. They do not document a non-obvious constraint or invariant. As per coding guidelines, "
**/*.{ts,tsx,js,jsx}: Default to writing no comments. Only add one when the WHY is non-obvious`."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/vite/routes/svgl.ts` around lines 5 - 6, Remove the endpoint-description comments above the route implementation in the svgl module, leaving the route behavior and surrounding code unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/core/src/vite/routes/svgl.ts`:
- Around line 5-6: Remove the endpoint-description comments above the route
implementation in the svgl module, leaving the route behavior and surrounding
code unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c0e706a0-35b8-4155-8aee-36d705e66b95
📒 Files selected for processing (26)
.changeset/brave-paths-follow.mdpackages/core/src/app/components/image-placeholder.tsxpackages/core/src/app/components/sidebar/sidebar-footer.tsxpackages/core/src/app/components/style-panel/use-design.tspackages/core/src/app/lib/assets.tspackages/core/src/app/lib/dev-api.test.tspackages/core/src/app/lib/dev-api.tspackages/core/src/app/lib/folders.tspackages/core/src/app/lib/inspector/use-comments.tspackages/core/src/app/lib/inspector/use-editor.tspackages/core/src/app/lib/inspector/use-notes.tspackages/core/src/app/lib/use-restart-server.tspackages/core/src/app/routes/slide.tsxpackages/core/src/vite/design-plugin.tspackages/core/src/vite/notes-plugin.tspackages/core/src/vite/routes/assets.tspackages/core/src/vite/routes/base-routing.test.tspackages/core/src/vite/routes/comments.tspackages/core/src/vite/routes/edit.tspackages/core/src/vite/routes/folders.tspackages/core/src/vite/routes/mount.test.tspackages/core/src/vite/routes/mount.tspackages/core/src/vite/routes/restart.tspackages/core/src/vite/routes/slides.tspackages/core/src/vite/routes/svgl.tspackages/core/src/vite/routes/update.ts
|
@1weiho would you mind taking a look? |
Fixes #392
When
OpenSlideConfig.baseis a non-root path, the UI renders fine beneath the base but all dev authoring APIs break: the client issues root-absolutefetch('/__folders')-style requests that escape the mount behind a reverse proxy, and the Connect middleware is only registered at root paths, so requests arriving as/<base>/__*fall through to Vite's SPA HTML handling.Changes
Client — new
devApiUrl()helper inapp/lib/dev-api.tsjoinsimport.meta.env.BASE_URL(the same signal #173/#207 used for the router basename and presenter URLs) with the dev API path. Every/__*fetch across folders, slides, editing, notes, comments, design, assets, svgl, update, and restart now goes through it, as do the constructed asset/svgl proxy URLs used as image sources.Server — new
mountDevRoute()/devRoutePaths()helpers invite/routes/mount.tsread the resolvedserver.config.baseand mount each route beneath the base first, keeping the root mount for direct probes and pre-base clients (withbase: '/'registration is unchanged — a single root mount). Used by allroutes/*registrations plus the design and notes plugins. Asset URLs embedded in JSON responses are base-prefixed viawithBase().Tests (written first, TDD)
vite/routes/base-routing.test.ts— HTTP-level reproduction of the issue over a connect-style mount stack: withbase: '/my-slides/',GET /my-slides/__folderspreviously fell through totext/html(the exact failure in the report) and now returnsapplication/json; root probes and SPA fallback for non-API paths still behave. Plus a route-inventory sweep asserting every dev API route group (including/__designand/__notes) mounts both beneath a nested base and at root.vite/routes/mount.test.ts— unit coverage fordevRoutePaths/withBase/mountDevRouteacross/, nested, trailing-slash-less, deep, and relative bases.app/lib/dev-api.test.ts—joinBase/devApiUrlunderBASE_URL='/'and'/my-slides/'(viavi.stubEnv), plus a source scan guarding against future root-absolutefetch('/__…')call sites insrc/app.Red run before the fix: the nested-base routing test failed with
expected 'text/html' to contain 'application/json'; after the fix all 329 tests pass.pnpm typecheckandpnpm checkare clean, and a changeset (patch,@open-slide/core) is included.Summary by CodeRabbit
Bug Fixes
Tests