HTTPS request in NodeJS
Solution 1:
Comparing what headers curl and node sent, i found that adding:
headers: {
accept: '*/*'
}
to options
fixed it.
To see which headers curl sends, you can use the -v
argument.curl -vIX GET https://openshift.redhat.com/broker/rest/api
In node, just console.log(req._headers)
after req.end()
.
Quick tip: You can use https.get()
, instead of https.request()
. It will set method to GET
, and calls req.end()
for you.