I am writing an application with Angular.js and Node.js.
There is a client-side app written in HTML & Angular.js that needs a web server like Apache to be online.
There is also a server-side REST webservice written in Node.js, built on restify
(but I don't care which REST API I use, I can use another one).
I can get the whole thing working using a Node.js server for the REST webservice, and another Node.js server for serving the client-side webapp. But I'd like to have only one Node.js server running, on one URL/port (to prevent cross-domain AJAX requests).
How can I do so?
Node. js is an open source server environment.
The standard they use for this is called Representational State Transfer (REST), and it works perfectly with the Node. js development techniques. Owing to this level of compatibility building a Node js REST API makes absolute sense.
Yes, and yes. Node and Apache / PHP can co-exist on a single server. The only issue you are likely to run into is that they cannot both listen on the same port. HTTP, by default, runs on port 80 and only one process can "listen" on a single port at any one time.
Not sure if this is applicable to your current problem - but app.use()
in Express can let one main application set sub-applications to handle different route prefixes. So you could have your main application point any requests starting with /store/
to one Express app, and any requests to /app/
with a second Express app.
http://expressjs.com/api.html#app.use
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With