How to organize the REST API and website frontend?

Asked

Viewed 955 times

0

I am creating a Single Page Application site, for this, I created a Restful API on Node.js that does all the actions in the database, login, sending emails and etc. I thought of creating a "public" folder in my project and put my front end there. But I think at some point I’m going to have a conflict between the Node.js and my front-end routes. I thought about leaving the API running on one port and the front end running on another port. As if they were separate projects.

What is the most used form in the organization of projects that use Single Page Application, restful API and etc?

  • I understand that this subject would probably be better discussed on chat, because there is no ideal solution that meets anyone. It depends a lot on the opinion and experience of each developer, and mainly on the individual proposal of each project. It is a valid question, maybe the answers cannot be so valid, because there is a great chance that the question attract "personal testimonials" that could be mistaken as technical answers, which is not so suitable for the format of questions and objective answers of the site.

1 answer

0


When I create applications of this kind I do the way you’re building. I leave my application in Ode running in one container and my web application running in another. I think it’s the best way to make this communication between them (using Vue.js on the front end). Since Node is serving an API to your front-end I see no problem doing so.

It might be nice to also separate Node and application into separate servers. But I don’t think it’s your intention.

There is no "right" way to build something like this. It will depend a lot on how you like to build your application and [important] how it will be used. If you’re using it in other application types, like an android/Ios app, you might want to separate the back-end application from the front-end to avoid what you said: conflict.

There is no right answer to that question, but I think I can understand it. Hugs! D

  • Thanks, Lucas. I’m also using Vue to build the front end of the application. Thanks for the answer, very enlightening.

  • Glad you could help! Hugs!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.