Reputation: 264391
Setting up a nodejs server to serve the REST interface (with json objects) to my application. This works fine.
Currently I run Jekyll service to provide the content pages. This causes some cross site scripting issues as they are running on different ports. I can get around this but it does not seem like the optimal solution.
Is it normal to run a nodejs server to provide the REST interface and the web content interface on the same port. I have been looking at nodejs/express/Swig as a replacement for the Jekyll service but I it seems that running the express/Swig on nodejs will alter the behavior of my response objects that makes using REST not quite as optimal.
Upvotes: 0
Views: 189
Reputation: 146014
Is it normal to run a nodejs server to provide the REST interface and the web content interface on the same port
Yes, this is pretty common as it is much simpler to deal with, so many small apps/apis opt for this approach. Sometimes the API uses a URL path prefix like '/api' as a basic distinction. Sometimes folks use content negotiation where '/user/42' will send either HTML or JSON depending on the request `Accept' header.
However, it is also common to use a web server on port 80 that routes to different back end apps based on a path, so for example anything to /api
would be reverse proxied to an express app on 127.0.0.1:3000
but everything else looking for content pages might go to a jekyll app on 127.0.0.1:3001
.
Upvotes: 2