aboutsummaryrefslogtreecommitdiff
path: root/api/routes/getNodeInfo/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'api/routes/getNodeInfo/index.js')
-rw-r--r--api/routes/getNodeInfo/index.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/api/routes/getNodeInfo/index.js b/api/routes/getNodeInfo/index.js
index 877b55a..d99382a 100644
--- a/api/routes/getNodeInfo/index.js
+++ b/api/routes/getNodeInfo/index.js
@@ -2,7 +2,7 @@ const { spawn } = require('child_process');
const akLogMessage = require('../../lib/akLogMessage');
module.exports = (req, res) => {
- akLogMessage('INFO', `Incoming from [${req.socket._peername.address}]:${req.socket._peername.port} @ ${req.get('host')}${req._parsedOriginalUrl.pathname}`);
+ akLogMessage('INFO', `Incoming from [${req.connection.remoteAddress}]:${req.socket._peername.port} @ ${req.url}`);
const command = spawn("ak-config", ["--get-published"]);
var buffer = "";
command.stdout.on("data", data => {
@@ -10,15 +10,16 @@ module.exports = (req, res) => {
});
command.stderr.on("data", data => {
- console.log(`stderr: ${data}`);
+ console.log(`stderr: ${data}`);
});
command.on('error', (error) => {
- console.log(`error: ${error.message}`);
+ console.log(`error: ${error.message}`);
});
command.on("close", code => {
- res.send(JSON.parse(buffer));
- console.log(`child process exited with code ${code}`);
+ res.writeHead(200, { 'Content-Type': 'application/json'});
+ res.end(buffer);
+ console.log(`child process exited with code ${code}`);
});
};