-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix/issue 5200 web base path #8589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: preview
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughIntroduces configurable base-path support (VITE_WEB_BASE_PATH / APP_BASE_PATH), switches manifest/static hrefs to joinUrlPath(WEB_BASE_PATH,…), normalizes manifest icon paths to relative, replaces WEB_BASE_URL with WEB_URL usages, and adds client-side mount guards to HydrateFallback across admin/space/web. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@apps/admin/app/`(all)/(dashboard)/workspace/create/form.tsx:
- Line 40: The current line double-encodes WEB_URL and uses a fallback that
omits the app base path; update the workspaceBaseURL logic: stop calling
encodeURI on WEB_URL (use WEB_URL as-is) and build a fallback that preserves the
origin plus the app base path from window.location.pathname (e.g., reconstruct
origin + first path segment(s) so the base path isn't lost) when WEB_URL is
undefined; locate and change the workspaceBaseURL constant in form.tsx
(references: workspaceBaseURL, WEB_URL, window.location).
In `@apps/web/app/layout.tsx`:
- Line 63: The head contains two <link rel="manifest"> tags pointing to
different files (site.webmanifest.json and manifest.json) so the browser only
uses the first; pick one approach: either remove the duplicate link (delete the
extra <link rel="manifest"> that uses joinUrlPath(WEB_BASE_PATH, "...")
referencing the manifest you don't want) or merge the two manifest files into a
single consolidated manifest (combine icon entries and other fields, save as a
single filename) and update the remaining <link rel="manifest"> (the usage that
calls joinUrlPath and WEB_BASE_PATH) to point to the consolidated manifest;
ensure icon paths inside the chosen manifest are correct for the deployed
assets.
🧹 Nitpick comments (2)
turbo.json (1)
9-9: Addition ofBASE_URLto globalEnv looks correct.This ensures Turbo properly invalidates the build cache when the base URL configuration changes, which is necessary for the custom base path feature.
Nitpick: For consistency, consider placing
BASE_URLin alphabetical order (afterAPP_VERSION, beforeDEV)."globalEnv": [ "APP_VERSION", + "BASE_URL", "DEV", "LOG_LEVEL", "NODE_ENV", - "BASE_URL", "SENTRY_DSN",apps/web/public/site.webmanifest.json (1)
10-19: LGTM on relative paths. Consider providing properly sized icons.The switch to relative paths (
plane-logos/plane-mobile-pwa.png) is correct for base path support.However, both icon entries reference the same image file with different declared sizes (192x192 and 512x512). For optimal PWA quality, consider providing separate image files at each resolution to avoid browser scaling artifacts.
* feat: adding new copyright info on all files * chore: adding CI
ea2077c to
da879a3
Compare
Fix: Add custom base path support for subpath deployments
Description
Fixes #5200
This PR adds comprehensive support for deploying Plane on custom base paths (e.g.,
mydomain.com/plane), enabling reverse proxy deployments on subpaths. Previously, static assets and internal links failed when deploying on a subpath.Problem
When users deploy Plane on a subpath using reverse proxies, multiple issues occurred:
Static assets 404: Assets served without base path prefix
/plane/assets/file.js/assets/file.js→ 404 errorsBroken manifest links: PWA manifests referenced with absolute paths
/site.webmanifest.jsoninstead of relative pathsHydration mismatches: Server/client rendering differences in fallback components
Admin app redirects: "Redirect to Plane" and workspace links pointed to wrong URLs
The
spaceandadminapps already supported base paths viaVITE_SPACE_BASE_PATHandVITE_ADMIN_BASE_PATH, but thewebapp was missing this feature, and cross-app navigation was broken.Solution
1. Web App Base Path Support
Added
VITE_WEB_BASE_PATHconfiguration following the same pattern as other apps:vite.config.tsto usejoinUrlPathutility and set Vite'sbaseoptionDockerfile.webto acceptVITE_WEB_BASE_PATHbuild argument2. Manifest Path Fixes
Fixed hardcoded manifest paths across all apps to support subpaths:
/site.webmanifest.json) to usejoinUrlPath()with base path/)3. Hydration Fixes
Resolved React hydration mismatches in
HydrateFallbackcomponents:web,admin, andspaceapps4. Admin App Cross-Navigation
Fixed admin app links to respect web app's custom base path:
WEB_URL(includes base path)5. Configuration & Documentation
BASE_URLtoturbo.jsonglobalEnv for linting.env.examplefiles withVITE_WEB_BASE_PATHdocumentationAPP_BASE_PATHconfigurationChanges
Core Files Modified
Web App:
apps/web/vite.config.ts- Base path configurationapps/web/Dockerfile.web- Build argument supportapps/web/app/root.tsx- Manifest path fix, hydration fix, React importapps/web/app/layout.tsx- Manifest path fix, base path supportapps/web/public/manifest.json- Relative icon paths, relative start_urlapps/web/public/site.webmanifest.json- Relative icon pathsapps/web/.env.example- DocumentationAdmin App:
apps/admin/app/root.tsx- Manifest path fix, hydration fix, React importapps/admin/app/(all)/(dashboard)/sidebar-help-section.tsx- Use WEB_URL for redirectapps/admin/app/(all)/(dashboard)/workspace/create/form.tsx- Use WEB_URL for previewapps/admin/core/components/workspace/list-item.tsx- Use WEB_URL for linksapps/admin/public/site.webmanifest.json- Relative icon pathsapps/admin/.env.example- DocumentationSpace App:
apps/space/app/root.tsx- Hydration fix, React importapps/space/public/site.webmanifest.json- Relative icon pathsapps/space/.env.example- DocumentationConfiguration:
turbo.json- Added BASE_URL to globalEnvpackages/constants/src/endpoints.ts- Already had WEB_URL supportapps/api/.env.example- Documentation for backend base pathTesting
Local Development Test:
Production Build Test:
Verification:
/plane/assets/.../plane/site.webmanifest.json/plane//plane/prefixBackward Compatibility
✅ Not a breaking change
VITE_WEB_BASE_PATHis/(root path)Checklist
Related
apps/space/vite.config.ts,apps/admin/vite.config.tsSummary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.