Fede
Fede

Reputation: 3

I need to add "Authorization" to headers without Postman

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

Answers (1)

Heiko Theißen
Heiko Theißen

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

Related Questions