Search code examples
angularangular-routercapacitor

CapacitorJS not serving root index.html for angular application


I'm using CapacitorJS to turn my Angular web application into a mobile app. However, I have an issue.

These are the devices I've tested this on:
Pixel 4a emulator (Android 11), iPhone XR (iOS 15), Xiaomi Redmi Note 8 (Android 11)

Version(s):
@angular/core, router 13.0.2
@capacitor/core, android, ios 2.4.0

Repro:

  1. I open my app
  2. Javascript files are taken from /
  3. I click a button to navigate to /example
  4. Javascript files are still taken from /
  5. I set the phone to sleep mode and wait (until js file need to be loaded again on app launch)
  6. I unlock the phone again
  7. Javascript files are taken from /example

Expected behavior:
Application javascript is taken from /

Actual behavior:
Application javascript is taken from /example (where it does not exist because /example is an Angular route)

Has anyone else experienced this issue, or have a solution for this?


Solution

  • Soved
    The issue was I was that I had ./ as baseUrl instead of / for angular :(