I'm trying to write a REST-API server with NodeJS like the one used by Joyent, and everything is ok except I can't verify a normal user's authentication. If I jump to a terminal and do curl -u username:password localhost:8000 -X GET, I can't get the values username:password on the NodeJS http server. If my NodeJS http server is something like

The third line in the example already does this by splitting the header on whitespace to produce ["Basic","abcdef0123456789"] and popping off the last value, which will be the authorization token.
–
Rob RaischJun 25 '12 at 21:44

It's much better to use the express.basicAuth method instead to handle all the issues. Simpler and cleaner.
–
Baruch EvenDec 27 '13 at 11:03