Return JSON in android device from API


I am developing an application with capactior and ionic/angular (latest version), and I am facing the following problem:
From the browser I retrieve data correctly from a proprietary API, but from the APK compiled and installed on a device it does not retrieve anything.
The API has the following header, as I saw that it could be a CORS issue, without them it doesn’t work either:

  • header(‘Access-Control-Allow-Origin: *’);
  • header(‘Content-Type: application/json’);
  • header(“Access-Control-Allow-Methods: GET, POST, OPTIONS”);
  • header(“Access-Control-Allow-Credentials: false”);

From the device if I access the URL of the API also works, I am importing the following packages:

  • import { HttpClient } from ‘@angular/common/http’;
  • import { Injectable } from ‘@angular/core’;

And return the result:

getAlertas() {
    const url = '';
    const params = {};
    return this.http.get(url, params);

And the view is a simple list with *ngFor=let articulo of articulos | async


It looks like you are using http instead of https so it is probably a clear text issue on Android. It is highly recommended to use https in production.

To get around the issue, see Unable to carryout HTTP post on Android - #2 by twestrick