lugia-ysstech / spa-demo

SingleSPA Demo
4 stars 2 forks source link

Return 404 Not Found when refreshing the url on browser after running with nginx #6

Open qweisong opened 4 years ago

qweisong commented 4 years ago

Hello:

The projects are building and running well, but got one big problem. It will return 404 Not Found when refreshing the url on browser. For example, if just open the url: http://localhost:8081/vue#/, it will show the error. It is because of the routing mechanism or because of the nginx config?

here is the nginx conf file: worker_processes 1;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream;

sendfile        on;
keepalive_timeout  65;

#gzip  on;

server {
    listen       8081;
    server_name  localhost;

    #location /vue {
    #root   E:\sunDemo1\sop\dist;
    #index  index.html index.htm;
    #try_files $uri /index.html;
    #   proxy_pass  http://localhost:3000/;
    #}

    location / {
        root   E:\sunDemo1\sop\dist;
        index  index.html index.htm;
    #    proxy_pass  http://localhost:3000/;
    }
}

server {
    listen       3000;
    server_name  localhost;

    location / {
        root   E:\sunDemo1\vue\dist;
        index  index.html index.htm;
    }
}

}

zenjava commented 4 years ago

Are you open http://localhost:8081/ is '404 Not Found' too ?

qweisong commented 4 years ago

With 8081, it works well. It only happens when refreshing the url of subprojects.