Forget data in IonicStorage during migration cordova app to capacitor 5 app

Hello,

I’ve got a problem during my app migration cordova → capacitor v5. (ionic 6)

I use storage from @ionic/storage-angular v3. I have no specific configuration (i use default value).

My data are stored in indexedDB with default name _ionicstorage.

During my migration, my data are lost. I’m trying to understand.

I checked the driver on 2 apps → asyncStrorage.

The unique difference i found is on origin: http://localhost with cordova app, httpS://localhost with capacitor app.

Can anyone help me?

Thanks

If the origin is changing then from my understanding your storage resets so that is the reason. Not sure why you have https with Capacitor. By default, it is http.

The default is https since Capacitor 5, you can change it to http by changing the value of androidScheme in the capacitor config file.

1 Like

Are you sure? Looking at the Docs, the default in v5 is http. The default to https is v6 (which is still in beta).

Yes, the default value in code is http, but all Capacitor 5 apps are created with the androidScheme set to https in the config file so they use https even if it’s not the native default.

Was done that way to avoid data loss going from Capacitor 4 to Capacitor 5 and give extra time to switch to https or manually set it to http if users want to avoid data loss when updating to Capacitor 6.

1 Like

Thanks guys,

The origin is the problem. i had set to capacitor.config an androidScheme=https.

So the solution is: keep the same origin

1 Like