Several problems about the Cooperation between react and nodejs

I just learned from react to write a spa single-page application. I know a little about "nodejs+koa2+ template" to build a simple website, but it is confusing to combine react+koa2:
1, can a single spa page be used simultaneously with backend template rendering on a website? Spa single page jumps to a web page rendered by the backend template through the a tag? And then how do you jump back to spa?
2, how does the back end tell when to return a page and when to return json? Is it usually distinguished by routing or something else?
3, should the route verification of unlogged-in redirection be done in spa or on the server?
Thank you first!

Jun.15,2022

in this case, I think it is necessary to record all the front-end routes of spa, and if these routes are in koa, return the index.html of spa.
answer 1. Only whether it is suitable or not, there is no unavailable, if forced to use together, it is technically feasible. A can jump when you find the template rendering file, and the template-> front-end route will be able to spa, as long as you follow the above processing
answer 2. Record the front-end route, and the front-end route returns index.html. Other routes return json
answer 3. Can be found in spa
another: it is recommended that spa can be separated from the server side. API requests for cross-domain processing. Nginx (spa static file) + koa (server side), front and rear are separated. You should solve most of the above problems

.
Menu