# Npx adalo login fails (Custom Component)

**URL:** <https://forum.adalo.com/t/npx-adalo-login-fails-custom-component/15346>\
**Category:** Get Help\
**Created:** [July 27, 2021, 2:51am UTC](https://forum.adalo.com/t/npx-adalo-login-fails-custom-component/15346 "2021-07-27T02:51:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![asi](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@asi](https://forum.adalo.com/u/asi)\
**Post date:** [July 29, 2021, 6:26am UTC](https://forum.adalo.com/t/npx-adalo-login-fails-custom-component/15346/2 "2021-07-29T06:26:10Z")

</div>

I fixed the issue by myself. It was related to a proxy. You need to make `@adalo/cli` proxy-aware if you are working behind a proxy like me.

# How to make `@adalo/cli` proxy-aware:

## Step 1

Make sure you have the `HTTPS_PROXY` environment variable.  
`$ echo %HTTPS_PROXY%`  
should print your proxy server address and port number, for example,  
`http://proxy.your-company.com:8080`  
`http://username:password@proxy.your-company.com:8080`

## Step 2

Install https-proxy-agent by running  
`C:\...\my-component>npm install --save-dev https-proxy-agent`

## Step 3

Fix some codes in `@adalo/cli`.

In `.\node_modules\@adalo\cli\src\login.js`,  
replace

```auto
const axios = require('axios')

```

with

```auto
const HttpsProxyAgent = require('https-proxy-agent')
const axiosDefaultConfig = {
  proxy: false,
  httpsAgent: new HttpsProxyAgent(process.env.HTTPS_PROXY),
}
const axios = require('axios').create(axiosDefaultConfig)

```

 ![adalo_fix_login](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/e/e32ada737b6038d23f45eee83a14721a99d95b93.png)

In `.\node_modules\@adalo\cli\src\dev.js`,  
replace

```auto
  const socket = io(`${SERVER}/packager`, {
    query: {
      sessionToken: authToken,
      libraryName: config.name,
    },
  })

```

with

```auto
  const HttpsProxyAgent = require('https-proxy-agent')
  const httpsAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY)
  const ioOpts = {
    secure: true,
    rejectUnauthorized: false,
    reconnect: true,
    agent: httpsAgent,
  }
  const socket = io(`${SERVER}/packager`, {
    ...ioOpts,
    query: {
      sessionToken: authToken,
      libraryName: config.name,
    },
  })

```

 ![adalo_fix_dev](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/75bfd5cc674cc6ddd722747de43aab2c2afbae3b.png)

## Step 4

Confirm the issue is fixed.  
`$ npm run login`  
will show you a message “Login successful!”.  
`$ npm run start`  
will show you a message “Connected to server” on the bottom of the screen.

_ **FIXED!** _  
P.S. I hope `@adalo/cli` officially support connection via proxy for people working behind a corporate proxy like me. I believe it should contribute to Adalo’s growth. Please utilize this post as a reference.

---

_[View the full topic](https://forum.adalo.com/t/npx-adalo-login-fails-custom-component/15346)._
