0

When running my node.js application locally, I get nicely formatted JSON output with line breaks and spaces, like this:

{
  "foo": "bar",
  "asdf": "qwerty"
}

But when I run the same code in iisnode on Azure, I get this:

{"foo":"bar","asdf":"qwerty"}

Not that it makes any functional difference, and the latter one even saves some extra bytes, but it would be nice to know where the difference comes from.

Here is the code:

exports.test = function(req, res){
    var result = { foo : 'bar', asdf : 'qwerty'};
    res.send(result);
}
hsg
  • 3
  • 4

1 Answers1

0

The difference is likely with the NODE_ENV environment variable and express' default configurations:

app.defaultConfiguration = function(){
  // ...

  this.configure('development', function(){
    this.set('json spaces', 2);
  });

  // ...
};

Azure must have a different value for NODE_ENV (probably 'production') so the configure() callback gets skipped.

Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
  • Thanks, this was indeed the reason. I got the the 'development' settings in iisnode working by setting `node_env: development` in iisnode.yml. – hsg Mar 12 '13 at 12:03