0

I'm developing an Rest API in Node.js / express to expose resources (to Backend). And another web application that manages Sessions and interacts with the Rest API (to Frontend). API and WEB_APP, is in same domain, with subdomain in both:

  • Backend: api.example.com
  • 2 Frontend: www.example.com

The web application is accessed from client with angular.js.

The architecture would be for two situations:

Main_Rest_API <-> WEB_APP <-> Browser_User
Main_Rest_API <-> Rest_SDK <-> Client

My question is: This architecture is consistent? What would be the best way to implement this scheme?

Update:

I have to implement this architecture to provide Restfull via OAuth2 to third-party clients also

1 Answer 1

5

I don't really understand your question,

are you sure that you need separate servers for serving the web app and for the API? you'll need to handle cross domain requests this way.

if you don't actually need two servers, it'll be simpler to have one app, where /api/ routes (for example) are the REST API. then your AngularJS app can make AJAX requests to /api/ and / will serve the JavaScript web app.

again, I don't understand your question for the case you do need two separate servers.

Sign up to request clarification or add additional context in comments.

4 Comments

Would be to separate into two projects (Backend and Frontend). As to crossdomain, would be in the same domain with a subdomain: ex. api.example.com/v1/users
It can be two separate projects if you like. You get to architect your software however you see fit.
if your web app is at www.example.com and your api is at api.example.com it is a cross domain request.
Ok, thank you to everyone that responded! I have to implement this architecture to provide Restfull via OAuth2 to third-party clients also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.