I'm trying to replicate a very straightforward 'POST' API signout call with my Express app running on localhost. It should take the signout info and pass it from localhost to MY-SERVER
How it should look:
curl "http://MY-SERVER/api/2.2/auth/signout" -X POST -H "Auth:1245"
I'm using request.post, set in a separate route file "signout.js" (see below).
var express = require('express');
var request = require('request');
var cheerio = require('cheerio');
var router = express.Router();
var OnlineApiUrl = 'https://MY-SERVER/api/2.2/';
//Sign Out
router.post('/auth/signout', function(req, res) {
var authentication_token = req.query.auth_token;
request.post({
url: OnlineApiUrl + 'auth/signout',
headers: {
'Auth': authentication_token
}
}, function(err, response, body) {
var $ = cheerio.load(body);
var hasError = $('error').length;
if (hasError) {
response = {
http_code: $('error').attr('code'),
http_message: $('summary').text()
};
} else {
response = {
http_code: 204
};
}
return res.json(response);
});
});
module.exports = router;
From what I can tell it should work, yet when I run
curl https://localhost:8080/api/auth/signout?auth=12345 --cacert /etc/nginx/ssl/server.crt
It only returns "Cannot GET /api/auth/signout?auth=12345"
Any idea what I'm missing here? It only needs to pass that custom header, nothing else. I'm also not sure why it's giving me "Cannot GET" for a POST request either...