How to configure the History mode of Vue in Nginx?

because vue-router has "- sharp" by default, but when forwarding the address in Wechat"s official account, the address "- sharp", including all future addresses, will be removed directly, resulting in the inability to share the page.
so I set the route pattern to history, according to the official configuration of Vue, and because our project is rendered by the server, I set base to the corresponding mobile.

so that I can access the home page through www.xxx.com/mobile, and it"s normal to jump to other pages in the interface with vue-router.
but here comes the fucking problem. For example, if I share the www.xxx.com/mobile/A/B path to a friend, then my friend will report a nginx error if he visits this path directly.
then I added the following configuration to nginx, as officially recommended by vue.

   location / {
       try_files $uri $uri/ /mobile [mobile]
   }

but it still doesn"t work. How should I configure it here?


try this

 location /mobile {
       try_files $uri $uri/ /mobile [mobile]
   }
The problem of

is solved in another way at the back end. Instead of using Ngnix, he detects the route himself, and outputs the mobile.html static file as long as the path starts with / mobile.

Menu