So I'm pretty late to the Node.js party. Mainly because nobody invited me... Thanks. That said, I'm starting to work it out. I have come from an ASP classic background so there are a few things I have yet to understand.
If someone can point me in the right direction, that would be great. Thanks in advance.
So, I'm setting up a server the standard way.
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
This gives me a nice page at http://127.0.0.1:1337/
. Lovely.
The site I am building resides at http://newsite.dev/
. Is it possible (don't laugh) to setup the node server to run from a sub folder of my site, let say http://newsite.dev/api/
?
So then, any queries from client-side scripts can be sent to /api/
rather than http://127.0.0.1:1337/
.
EDIT:
To make things a bit clearer. I am currently running a custom PHP framework at http://newsite.dev/
, but looking to drop this long term. In the mean time, need to run them in parallel.
EDIT Again, to clarify, I am running everything on my OS X, so apache (MAMP) installation.