React project nginx configuration issues

there is a problem when using nginx to configure the front and back end to separate items. The front end is done with react and the routing is in history mode. The nginx configuration is as follows:

server {
    listen    8000;
    server_name   test;
    charset utf-8,gbk;
    location / {
        root /opt/web/test1;
        -sharpindex index.html index.htm;
        try_files $uri /index.html;
    }

    location /v1/ {
        proxy_pass http://127.0.0.1:8001/xxx/v1/;
    }
}

the front-end page can be accessed after configuration, but the path in the ajax request will be one more level of directory. The rules are as follows:

//url
http://localhost:3000/bill/query 
//  /bill :
http://localhost:3000/bill/v1/xxx/xxx/list 
// 
http://localhost:3000/v1/xxx/xxx/list 

similarly, if my url address is http://localhost:3000/test/query, the requested path will become http://localhost:3000/test/xxx/xxx/list.

.

the request is fine when I change the route in react to hash mode, that is, remove the try_files $uri / index.html; from the nginx configuration.
does any boss know why? thank you very much.

Feb.27,2021

when packing, configure publicPath


the reason is that when you configure url in the project, it is written as a relative path.
should add a / before url, as follows:

fetch('/vi/xxx/xxx/list');
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e978bd-1666.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e978bd-1666.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?