Skip to main content

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​

  1. Import { apiFetch, apiUrl } from src/lib/apiBase.
  2. Replace fetch('/api/...') with apiFetch('/api/...').
  3. Images/static API paths via apiUrl(path).
  4. No hard-coded routineassist.com in components — env/base resolver.
  5. Test in browser AND Android emulator after change.
  6. CORS: server must allow Capacitor origin.
  7. 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.

See also​