problem description:
during this period of time, I am working on a project, and Web mainly uses the NodeJs Koa framework, React, React-router,redux, and so on.
the front end React-create-app generates the project and build generates static files.
NodeJs Koa provides Api.
now it is mainly the deployment problem:
see on the Internet that there are several ways:
- nginx
my understanding is a nginx static server, which is mainly used for users to request to static resources, and
node is deployed separately and is only used to provide APi.
simply means that the front and rear ends are deployed separately. - isomorphic
Node returns directly to the page.
in that case, there are two questions
(1) how to tell whether the request is an api data interface or a page.
(2) routing problem, whether React-router controls routing or node. - returns the React packaged file as a static resource.
when a user requests a home page, he or she returns the packaged index.html,
and simply merges it into a project.
* * this will be a bit vague now.
by the way, the main question is how to release the front and rear separate projects,
the front end is clear.
it"s best to explain it in detail. Thank you. * *
split line--
add:
because my current project is a little simple. As long as you can run.
so I"m not going to use nginx
how can you simply integrate and use pm2 to make it run?
Front build into some static resource files.
how do I write it on the node side?
does not seem to work as a static resource, and all requests will return to this main page.
how should this block be written, or is there any example?