title: Network error: Failed to fetch on ionic react
body: <p>it's the first time that i post on forums,
  I really needs your help.
  I'm stuck with a problem, I have an Ionic/React application, a Node.js application and a graphQL/Apollo API,
  when i'm calling the graphql API from my browser it's all working fine but when i'm building the app with capacitor and running it on my Android device, I get &quot;Network error: Failed to fetch&quot;.</p>
  <p>Here is my client.ts code where i'm setting up my ApolloClient</p>
  <pre><code>import { ApolloClient } from 'apollo-client';
  import { createHttpLink } from 'apollo-link-http';
  import { setContext } from 'apollo-link-context';
  import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory';
  
  class RequestUtils {
  clientApollo: any;
  
   constructor() {
       const httpLink = createHttpLink({
           uri: 'http://192.168.1.86:4000/graphql'
       });
  
       const authLink = setContext((req, { headers }) =&gt; ({
           headers: {
               ...headers
           }
       }));
  
       this.clientApollo = new ApolloClient({
           link: authLink.concat(httpLink),
           cache: new InMemoryCache()
       });
   }
  }
  
  const requestUtils = new RequestUtils();
  const client: ApolloClient&lt;NormalizedCacheObject&gt; = requestUtils.clientApollo;
  
  export default client;
  </code></pre>
  <p>and here is my graphql.ts</p>
  <pre><code>import resolvers from &quot;../resolvers/index&quot;;
  import { ApolloServer, AuthenticationError } from &quot;apollo-server-express&quot;;
  import { getModels } from &quot;../models/index&quot;;
  import schemas from &quot;../schemas/index&quot;;
  import * as express from &quot;express&quot;;
  import * as cors from &quot;cors&quot;;
  import { connectToMongo } from &quot;./config&quot;;
  import { info, success, warning, error } from &quot;./logger&quot;;
  
  export class query {
      public app: any;
      constructor() {
          const models = getModels();
          this.app = express();
          this.app.use(cors());
          try {
              info(&quot;Starting connection to graphql&quot;);
              const server = new ApolloServer({
                  typeDefs: schemas,
                  resolvers,
                  context: async ({ req }) =&gt; {
                      if (req) {
                          return {
                              models: models
                          };
                      }
                  }
              });
              this.app = express();
              server.applyMiddleware({ app: this.app, path: &quot;/graphql&quot; });
              success(`Connected to graphql`);
          } catch (error) {
              warning(error);
          }
          this.app.listen(4000, () =&gt; {
              connectToMongo();
          });
      }
  }
  </code></pre>
  <p>I think that it's a problem with something like cors or ip adress but i don't find any solution to my problem.
  I hope someone can help me !</p>
  <p>EDIT:</p>
  <p>I tried to run my node server on another computer and cal the graphql API from my main computer with my ionic react react webapp. The origin is in fact different but there is no error, all works perfectly. But with my builded app on my android device, always same error.</p>
  <p>So, I think it's not cors, maybe it's something with Capacitor/cordova, or something like this.</p>
  <p>At first, i thought android app wasn't allowed to connect to network, I checked and it's connected, but I'm not sure.</p>
  <p>If someone could help me, it would be very sympathic , I'm really stuck with this, my app is useless if i can't connect to server en database XD</p>