# Proxy url in my package.json is not taken into consideration by Android Studio

**URL:** <https://forum.ionicframework.com/t/proxy-url-in-my-package-json-is-not-taken-into-consideration-by-android-studio/209771>\
**Category:** Ionic React\
**Created:** [May 20, 2021, 7:28am UTC](https://forum.ionicframework.com/t/proxy-url-in-my-package-json-is-not-taken-into-consideration-by-android-studio/209771 "2021-05-20T07:28:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ani4](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Ani4](https://forum.ionicframework.com/u/Ani4)\
**Post date:** [May 20, 2021, 7:28am UTC](https://forum.ionicframework.com/t/proxy-url-in-my-package-json-is-not-taken-into-consideration-by-android-studio/209771/1 "2021-05-20T07:28:00Z")

</div>

I have developed an `Ionic React app` , running on top of `Capacitor` . In browser everything runs smoothly (ionic serve).

Now I’m trying to run my app on an `Android emulator` , but my login button is not working. I click on it and nothing happens. In `LogCat` I see this log when I click on the button:

`/io.ionic.starter D/Capacitor: Handling local request: http://localhost/login`

In order to solve **CORS issues** , in `package.json` I’m using a proxy: ` "proxy": "https://xx.xx.xx",`

In Login Component, I’m calling a `POST axios request` in order to login with cardNumber and birthday.

Login Component:

```auto
import React from "react";
import { useHistory } from "react-router-dom";
import { useState, useContext } from "react";
import axios from "axios";
import {
  ...
} from "@ionic/react";

const Login = () => {
  const history = useHistory();
  const {
    cardNumber,
    setCardNumber,
    birthday,
    setBirthday,
    iserror,
    setIserror,
    message,
    setMessage,
  } = useContext(MyContext);

  const doLoginwithBirthday = (e: any) => {
    e.preventDefault();
    setIserror(false);

    const data = {
      cardNr: cardNumber,
      birthDate: birthday,
    };
    

    axios
      .post("/login", data)
      .then((response) => {
        if (response.data.token) {
          history.push("/home");
          window.location.reload();
        }
        return response.data;
      })
      .catch((error) => {
        setMessage(
          "Try again!"
        );
        setIserror(true);
      });
  };

  return (
    <IonPage>
      <IonHeader></IonHeader>
      <IonContent className="ion-padding ion-text-center">
        <IonGrid>
          <IonRow>
            <IonCol>
              <IonAlert
                isOpen={iserror}
                onDidDismiss={() => setIserror(false)}
                header={"Info!"}
                message={message}
                buttons={["OK"]}
              />
            </IonCol>
          </IonRow>
        
                <h1>Login</h1>
            
              <IonItem>
                <IonLabel position="floating">Card Number</IonLabel>
                <IonInput
                  name="cardNumber"
                  type="number"
                  value={cardNumber}
                  onIonChange={(e) => setCardNumber(e.detail.value!)}
                />
              </IonItem>

             
              <IonItem>
                <IonLabel position="floating">Birthday</IonLabel>
                <IonInput
                  name="birthday"
                  type="text"
                  value={birthday}
                  onIonChange={(e) => setBirthday(e.detail.value!)}
                />
              </IonItem>
              <br />
              <IonButton onClick={doLoginwithBirthday}>Login</IonButton>
             
              <IonItem
                lines="none"
                routerLink="/register"
                class="ion-text-right"
              >
                <IonLabel>Register</IonLabel>
              </IonItem>
           
        </IonGrid>
      </IonContent>
    </IonPage>
  );
};
export default Login;

```

How is it possible that clicking the Login button handles the request: `http://localhost/login` instead of [https://xx.xx.xx/login](https://xx.xx.xx/login) ? It seems that proxy is not taken into consideration by Android. How can I solve this? Should I change anything on Android ?

**capacitor.config.json**

```auto
{
  "appId": "io.ionic.starter",
  "appName": "testApp",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "build",
  "plugins": {
    "SplashScreen": {
      "launchShowDuration": 0
    }
  },
  "cordova": {}
}

```

---

<div class="post-metadata">

**Author:** ![elylucas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/elylucas/32/137716_2.png) [@elylucas](https://forum.ionicframework.com/u/elylucas)\
**Post date:** [May 21, 2021, 10:12pm UTC](https://forum.ionicframework.com/t/proxy-url-in-my-package-json-is-not-taken-into-consideration-by-android-studio/209771/2 "2021-05-21T22:12:30Z")

</div>

Proxing requests is only done when you are using the react dev server from your local machine. When you run on Android, the app is being served from the phone itself, and not the dev server.

I haven’t tried this, but you might have luck using live reload and the proxy request together: [Capacitor - build cross platform apps with the web](https://capacitorjs.com/docs/guides/live-reload)

---

<div class="post-metadata">

**Author:** ![Ani4](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Ani4](https://forum.ionicframework.com/u/Ani4)\
**Post date:** [May 28, 2021, 11:02am UTC](https://forum.ionicframework.com/t/proxy-url-in-my-package-json-is-not-taken-into-consideration-by-android-studio/209771/3 "2021-05-28T11:02:17Z")

</div>

I solved this issue, using capacitor community http plugin: [GitHub - capacitor-community/http: Community plugin for native HTTP](https://github.com/capacitor-community/http). There is a lack of info here, but anyone interested can reply to this comment.
