'@' in URL, used in node.js http.request

I'm presented with an url with an "@" sign in it:

curl http://subdomain:token@localhost:9292/aaa/bbb

works perfectly

But I can't get it to work with node.js http.request, probably because I don't understand what the "@" is doing (and somehow can't find a clear answer on google).

Anyone care to explain?

Here's my current node.js code

var http_options = {
  method : "GET"
, url : subdomain + ":" + token + "@" + Config.API.url
, path : "/aaa/bbb"
};

var req = http.request(http_options, function (response) {
  // ...
});

req.on('error', function (error) {
  console.log('error: ' + error);
});

which produces:

error: ECONNREFUSED

The @ is dividing the user / password part from the location part.

the curl line you wrote send a HTTP Authenticate (BASIC authentication) with the request.

curl http://subdomain:token@localhost:9292/aaa/bbb

means: Get localhost:9292/aaa/bbb and do it as user: subdomain password token

I have no idea how to do that in node.js, but you'll figure it out, now that you know what it does.