Reputation: 358
I want to build a rest api for a project management web and apps. My first option is Node.js, there's tons of frameworks and ways to create a rest api with node.js. This apps would also include real time features (chat). Socket.io seems like a good plan for that, but how can I merge both?
Edit: I'll try to explain it better.
I want to create a Rest api and also a websocket server that works for web and also mobile apps. I've tried socket.io but can't make it work if not of the same server.
Is it possible to host socket.io on one server and use it from another server/app?
Upvotes: 0
Views: 2244
Reputation: 3488
Socket.io does support cross-domain requests.
Technically there should be no problem binding the socket to http://server1/chatServer
from http://server2/chatClient.js
Just bind your client side socket to your API address:
var socket = io.connect('http://server1/chatServer');
Here is an SO question on the socket.io subject.
If you are going to call your REST API via AJAX from the different domain, you might run into cross-domain request problems. This question should help you with those.
Upvotes: 2