Reputation: 15454
I have username
and password
and I want to compute Authorization
header for HTTP Basic Auth. Computed header looks like this: 'Basic xyz123xxx'
. Is there a node package in npm that will allow me to do this?
Upvotes: 7
Views: 5212
Reputation: 799210
Use Buffer
to encode the string for use in the header.
Buffer.from(`${username}:${password}`).toString("base64")
Upvotes: 14