feat: disabled server authorization in dev mode according to https://stackoverflow.com/questions/51363855/how-to-configure-axios-to-use-ssl-certificate
This commit is contained in:
parent
06abf48a86
commit
ab878373f3
18
index.js
18
index.js
|
@ -11,6 +11,18 @@ debug('USR: '+USR)
|
||||||
const KEY=process.env.KEY||'KEY';
|
const KEY=process.env.KEY||'KEY';
|
||||||
debug('KEY: '+KEY)
|
debug('KEY: '+KEY)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable server authorization only in development mode
|
||||||
|
*/
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
const https = require('https');
|
||||||
|
const httpsAgent = new https.Agent({
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
})
|
||||||
|
axios.defaults.httpsAgent = httpsAgent
|
||||||
|
debug('%s RejectUnauthorized is disabled.',process.env.NODE_ENV)
|
||||||
|
}
|
||||||
|
|
||||||
run().catch(err => {
|
run().catch(err => {
|
||||||
debug('run: error')
|
debug('run: error')
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -30,8 +42,10 @@ async function run() {
|
||||||
username: `${USR}`,
|
username: `${USR}`,
|
||||||
password: `${KEY}`
|
password: `${KEY}`
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
res.status; // 200
|
).then(res => res.data);
|
||||||
|
// );
|
||||||
|
// res.status; // 200
|
||||||
|
|
||||||
debug('data received via GET');
|
debug('data received via GET');
|
||||||
debug('dataGet len: %s',dataGet.length)
|
debug('dataGet len: %s',dataGet.length)
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nodemon index.js",
|
"dev": "nodemon index.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "Stefan Begerad",
|
"author": "Stefan Begerad",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"https": "^1.0.0",
|
||||||
"nodemon": "^2.0.7"
|
"nodemon": "^2.0.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in New Issue