解决SPA单页面应用(create-react-app,Vue-cli)路由跳转后404的问题。

在Nginx中配置try_files

server {
        listen        80;
        server_name  localhost;
        root   "****";
        location / {
	    try_files $uri $uri/ /index.html;
            index index.php index.html;
            error_page 404 /error/404.html;
            include ***;
            autoindex  off;
        }
	location /api/ {
            proxy_pass http://localhost:8055;
        }
}
posted @ 2022-11-19 10:02  skywa1ker  阅读(36)  评论(0编辑  收藏  举报