The problem of inconsistency between front-end routing and back-end routing

the background did not put my project in the root directory, but put it in an admin folder under the root directory, so when I visited my project, it appeared on the road, for example: 192.168.1.105 admin admin, but my foreground project route does not have the path of admin, so I can"t access it. Unless I add an example to my path: / admin/login, so that I can access it, but the workload is a bit heavy, so there is no other way to solve it.

Nov.19,2021

the backend uses the nginx agent to learn about


clipboard.png

https://router.vuejs.org/zh/a.


1. If the routing is controlled by the backend, you can refer to the following scheme

  • the backend modifies the nginx to type all / pages under / admin (but this may be a bit rough and even affect the backend's own interface. It is recommended that you add a prefix to the front end, similar to statics, so all requests of / statics will be typed under / admin)
  • the backend changes files to another folder ~
  • is it similar to an alias as mentioned above? I am a front-end developer, so I don't know much about the back-end, just prompt you to see if it is feasible

2. A more thorough plan

  • it is a trend to separate front and rear ends. It is convenient to develop independent services without relying on any back-end services, and you can also control routing yourself.

there are many solutions

  • some front-end routes support specifying base paths, such as vue-router
  • can also be solved at the web server level, and the path can be rewritten with rewrite
  • can also use proxy to delegate to other paths, but this may require communication with your backend or operators
Menu