Skip to content

Instantly share code, notes, and snippets.

@georgioupanayiotis
Created January 16, 2023 21:46
Show Gist options
  • Save georgioupanayiotis/4256128b202b813c67892482e655fdef to your computer and use it in GitHub Desktop.
Save georgioupanayiotis/4256128b202b813c67892482e655fdef to your computer and use it in GitHub Desktop.
Generating base64-encoded Authorization Node.js
var username = 'Test';
var password = '123';
var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
var header = {'Host': 'www.example.com', 'Authorization': auth};
var request = client.request('GET', '/', header);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment