Make routing work from a file-served Capacitor bundle (#24) #27

Merged
westfarn merged 1 commits from capacitor-file-routing-24 into master 2026-07-26 13:46:41 -07:00
Owner

Summary

  • Closes Make routing work from a file-served bundle (React Router 6 under Capacitor) (#24)
  • Introduce AppRouter + getAppRouter() so Capacitor uses HashRouter (filesystem bundle, no nginx rewrite) while web keeps BrowserRouter
  • Isolate platform checks in nativePlatform (no Capacitor.isNativePlatform() sprinkled through the route tree)
  • Auth forced redirects (axiosApi/signin/) use hash-safe redirectToAppPath on native
  • Leave CRA homepage / absolute PUBLIC_URL asset paths unchanged so /var/www/{env}.chat.aimloperations/html deploy stays intact; HashRouter keeps document URL at the bundle root so assets resolve

Test plan

  • Unit tests: AppRouter + nativePlatform (npm run test:ci)
  • Capacitor build: open nested route (/#/account/), force WebView reload — no blank/404
  • Browser back/forward + Android hardware back with HashRouter
  • Web deploy smoke: deep link reload at /account/ still works via nginx rewrite
  • Confirm login redirects after 401 still land on sign-in (web path + native hash)
## Summary - Closes #24 - Introduce `AppRouter` + `getAppRouter()` so Capacitor uses `HashRouter` (filesystem bundle, no nginx rewrite) while web keeps `BrowserRouter` - Isolate platform checks in `nativePlatform` (no `Capacitor.isNativePlatform()` sprinkled through the route tree) - Auth forced redirects (`axiosApi` → `/signin/`) use hash-safe `redirectToAppPath` on native - Leave CRA `homepage` / absolute `PUBLIC_URL` asset paths unchanged so `/var/www/{env}.chat.aimloperations/html` deploy stays intact; HashRouter keeps document URL at the bundle root so assets resolve ## Test plan - [x] Unit tests: `AppRouter` + `nativePlatform` (`npm run test:ci`) - [ ] Capacitor build: open nested route (`/#/account/`), force WebView reload — no blank/404 - [ ] Browser back/forward + Android hardware back with HashRouter - [ ] Web deploy smoke: deep link reload at `/account/` still works via nginx rewrite - [ ] Confirm login redirects after 401 still land on sign-in (web path + native hash)
westfarn added 1 commit 2026-07-26 13:42:17 -07:00
Use HashRouter for Capacitor file-served routes (#24)
Unit Tests / test (pull_request) Successful in 10s
02f14699b9
Isolate BrowserRouter vs HashRouter in AppRouter so nested paths reload
cleanly from the Capacitor filesystem bundle without nginx rewrites, while
web deploy keeps BrowserRouter unchanged.
westfarn merged commit 0fc8739d26 into master 2026-07-26 13:46:41 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_web_app#27