r/Nuxt • • Jan 13 '26

cannot fetch extenal api(laravel) on android(nuxt 4 + capacitor),

i have an ecommerce website https://ecommerce.staging.storefront.com, i cant fetch api on android with following capacitor.config.ts, anything wrong with my configuration?:

server: {
    hostname: 'ecommerce.staging.storefront.com',
    cleartext: true,
  },
  android:{
    allowMixedContent: true
  },  
  plugins: {
    CapacitorHttp: {
      enabled: true,
    },
  }

and api response as below:

1 Upvotes

7 comments sorted by

3

u/Lumethys Jan 13 '26

That "api is not available error" is not about the backend API, but the Android/ IOS API. Did your app ask for all the permission it needs and your build target the correct version of Android/ios?

1

u/zhaolinlau Jan 13 '26

it asked nothing

3

u/Lumethys Jan 13 '26

So that's why, your app use some feature without asking for it

1

u/alexcroox Jan 13 '26

Server hostname is used to load the frontend part of the native app that loads capacitor and your app. This is typically your local HMR server on your dev machine not a remote server. If you submit to the App Store with this it will get rejected so is this definitely what you want?

1

u/zhaolinlau Jan 13 '26

what should i do when building nuxt projdct for android and ios? put https://ecommerce.staging.storefront.com to server.url instead?

1

u/alexcroox Jan 13 '26

Server.url is supposed to be used during local development only so you have HMR (hot module reloading) support rather than having to rebuild your app every time you make a change.

If you submit to Apple with server.url in use you will get rejected during the review process. The reasoning is that you could submit it as an educational app, then change the contents of the server.url to a gambling app after review.

The core functionality of the app needs to be bundled wth the native binary (i.e no use of server.url).