Npx adalo login fails (Custom Component)

Hi,
$ npx adalo login
fails with the correct password like below.

Is there any solution or workaround?

I read @zachbharris’s post and tried
$ npx @adalo/cli login
but it also fails.

Versions:
npx: 6.14.13
npm: 6.14.13
node: 12.22.3

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

const axios = require('axios')

with

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

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

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

with

  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,
    },
  })

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.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.