Make routing work from a file-served bundle (React Router 6 under Capacitor) #24
Notifications
Due Date
No due date set.
Blocks
#20 Ship Android app by wrapping the web build with Capacitor
ai_ml_operations/chat_web_app
#21 Ship iOS app by wrapping the web build with Capacitor
ai_ml_operations/chat_web_app
Reference: ai_ml_operations/chat_web_app#24
Reference in New Issue
Block a user
Risk
Blocks #20 (Android) and #21 (iOS).
The app uses React Router 6 with
BrowserRouter. On the web, nginx rewrites unknown paths toindex.html, so a reload at/chat/123works. Under Capacitor the bundle is served from the local filesystem with no rewrite rule, so any load or reload at a nested path can resolve to a missing file and produce a blank screen or a 404. Anything that triggers a full reload (crash recovery, WebView restart after memory pressure, an external link back into the app) hits this.Work
HashRouterfor native,createMemoryRouter, or Capacitorserver.androidScheme/errorPathconfig that falls back toindex.html.Capacitor.isNativePlatform()checks through the route tree.PUBLIC_URL, asset paths, hardcoded/links, redirects after login, and anything callingwindow.location.homepagefield) so JS/CSS/fonts load from the bundled origin./var/www/{env}.chat.aimloperations/htmlis unaffected by the change.Done when
Every route loads and reloads cleanly in a Capacitor build on both platforms, assets resolve, and the web build behaves exactly as before.