typicode/json-server — pull request #15 by raulcesar (2014-07-03 19:23:19+00:00)
Title: Enable sending options to cors module

I had a problem when developing locally because my front-end (hosted on localhost port "a") uses the "withCredentials = true" header. This in turn causes an error when I access the json-server (which is hosted on localhost on port "b") which is: "A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true".

This can be corrected by sending in an options object to the cors module, specifying a specific origin, and the flag credentials: true (i.e.: {"origin":"http://localhost:63342","credentials":true}).

In order to accomplish this, I changed the way the express "server" is setup and exported and in turn changed the cli.js to receive the argument via command line argument and in turn pass it to the server.

I am relatively new to node (and javascript development in general), so if this alteration is complete nonsense, please let me know.