Do routes have to be written in order to separate front and back ends?

  node.js, question

Recently, I came into contact with express-based sails.js, a background framework using nodejs. When rendering front-end pages, it is realized through back-end routing. The template used for front-end pages is ejs. Due to the use of this development method, the front and rear ends are seriously coupled and the development efficiency is relatively low. What we want to do now is to separate the front and rear ends. First of all, I don’t understand the concept of routing very well. I would be grateful if the great gods could summarize it.

First, I can understand that the back-end writes routes and renders front-end pages. A lot of work is left to the back-end.

Second, if the back end does not write the route, the route will be handed over to the front end, and the browser will be used to complete the distribution of the route. As far as I know, I can use frameworks such as angular, vue or react to write the route. The message thus written belongs to SPA Single page application, and all the pages of the whole project are concentrated in one web page. I don’t know if my understanding is correct. Is this kind of route the so-called front-end route? Can the front-end route be used only when writing Single page application? If it is not Single page application, is there any need for routing?

Third, according to the question raised in Article 2, I tried to remove the routing configuration in the sails.js framework, which has this property. When there is no routing configuration, running the program, accessing in the browser, will identify and load the index.html file in the static resource folder. At the same time, an html folder is created in the static resource folder, and the page text.html is written in the html folder. index.html and text.tml can also jump on the browser normally. Is routing still effective at this time? In this case, the front end obtains json data through ajax and the back end provides API. Is it the separation of the front end and the back end? I wonder if this idea is too naive. So here I sum up a few questions:

1. Under what circumstances are front-end and back-end routes used?
2. Does the front-end route refer to the route in Single page application?
3. The back end provides API. The front end uses ajax to obtain data. Do you still need routing? Is routing necessary especially when node is used such as express and sails?

Dear gods, it’s really hard to watch so much. I’m a novice at the front end. I don’t understand a lot of things very well. I hope you understand and appreciate it.

First, routing has nothing to do with back-end rendered pages. I simply return a data can also be routed. So read the routing documents carefully. What is the back end and what is the front end?
Second, detailed statements are everywhere, Baidu has them, and I will say in a popular way that the essence of back-end routing is “binding processing logic and URI”. The essence of front-end routing is “jump”, in fact, it is also binding things and linking them. This is also a major function of the framework. Routing is to set up “where” and “what to do”.

Answer:
1. You understand what a route is and will use it when you need it. Both are used in the project. Now the more serious items are separated from the front and back.
2. Of course not, single page has nothing to do with front-end routing. Single page is a design pattern and front-end routing is a technology.
3. The front-end can obtain ajax data without front-end routing, and the back-end can give the data. Is there no route at the back end? Also, the backend receives the request to the data. No matter what framework is used, their rules are the same.