A
A
antraks2020-11-30 17:45:42
Nginx
antraks, 2020-11-30 17:45:42

Error 404 Not Found page occurs when refreshing the page nginx / 1.18.0 vue + nginx How to fix this?

There is an error when reloading the page
404 Not Found
nginx/1.18.0


If you add the # sign to the link

Example: 127.0.0.1:8080/#/url_page then the transition is made / How to fix this?

server { listen       80; server_name  localhost;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    rewrite ^/([^\.]+)$ /$1 break;
    add_header 'Access-Control-Allow-Origin' 'http://${BACKEND_ADDR}:${BACKEND_PORT}';
}

location /api/v1 {
    proxy_pass   http://${BACKEND_ADDR}:${BACKEND_PORT};
    proxy_http_version 1.1;
    client_max_body_size 100M;
}


location /api/v1/ws/ {
    proxy_pass http://${BACKEND_ADDR}:${BACKEND_PORT};
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2020-11-30
@Fragster

https://router.vuejs.org/ru/guide/essentials/histo...

M
Michael, 2020-12-01
@Byakko611

If I understood you correctly, then you do not like that the link works through #?
This was done by Vue Router and the feature is quite convenient, from it all your changes are loaded on the page in real time.
When you don't need it, just in the src/router/index.js file put in VueRouter - mode: 'history',

const router = new VueRouter({
  mode: 'history',
  ...
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question