API patterns
Goal
Web, Android and iOS (Capacitor WebView) work against the same server.
For whom
Frontend developers.
Where in the app
All API calls in src/; base URL via apiBase helper.
Prerequisites
Understanding Vite base: './' for relative assets.
Step by step
- Import
{ apiFetch, apiUrl }fromsrc/lib/apiBase. - Replace
fetch('/api/...')withapiFetch('/api/...'). - Images/static API paths via
apiUrl(path). - No hard-coded
routineassist.comin components — env/base resolver. - Test in browser AND Android emulator after change.
- CORS: server must allow Capacitor origin.
- Cap sync after asset/route change:
npm run cap:sync.
Options & settings
Relative image URLs break on Android file origin — always apiUrl.
Tips & troubleshooting
Grep for fetch('/api and src="/uploads before release.