0

I am trying to send a post request to a service from my node server. Node is running on http://localhost:3000. The method I am trying to reach is reachable through http://localhost:80/some/adress/business/layer/myMethod.

var options = {
    host: 'localhost',
    path: '/some/adress/business/layer/myMethod',
    port: '80',
    method: 'POST',
    headers: {
         'Content-type': 'application/json',
         'Content-Length': data.length
    }
};

var req = http.request(options, function (resu) {
    console.log('statusCode: ' + res.statusCode)

    resu.on('data', function (d) {
        console.log(d);
    });

    resu.on('error', function (err) {
                    console.log(err);
    });

    resu.on('end', function () {
        res.jsonp({ result: true });
        res.end();
    });
});

req.write("data");
req.end();

The request works fine, well more or less. I am getting a 401 status back. The question is: How can I send windows credentials from node to the named server running on localhost:80... ?

pregunta
  • 138
  • 1
  • 11

1 Answers1

1

Without knowing the exact details of your setup, I can't be sure, but you probably need to use NTLM authentication. There are several libraries that do this for node. Take a look at this question. Hope this helps!

Jason Bray
  • 502
  • 1
  • 4
  • 15
  • I am pretty new to node and figured it out to run the server through learning by doing to be honest. What do you need to know in detail? And thank you for the provided link I will take a look at it. – pregunta May 06 '19 at 13:01
  • I'm not an expert either, but in previous clients I've worked at, we used windows auth and NTLM worked for us. My disclaimer was more to the fact that I can't be 100% sure there isn't some other way to set things up on the back-end that would render my advice irrelevant – Jason Bray May 06 '19 at 20:21