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.