Reputation: 3
How i can add "Authorization" header in code, i use nodejs and express in my app, this is to do a login and i want to login without passing the "Authorization" header with Postman, thanks!
Upvotes: 0
Views: 423
Reputation: 16676
When your Node.js code makes an HTTP request using http.request
, it can insert an authorization header for Basic authentication as follows:
http.request(url, {
headers: {
Authorization: "Basic " + Buffer.from("username:password").toString("base64")
}
})
Upvotes: 1