I have SPA made with Vue.js.
I handle 404 at client side this way:
//at the end of router
{
path: '/404',
name: 'not-found',
component: () => import(...)
},
{
path: '*',
redirect: '/404'
}
Problem: when I'm trying to access some unexisting page on my dev environment, I got nginx default 404 page instead my Vue page.
Parts of Nginx config:
server {
index index.html;
location / {
try_files $uri $uri/ =404;
}
//ssl config managed by Certbot
}
server {
if ($host = <...>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <...>;
listen 80;
}
server {
if ($host = <...>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <...>;
listen 80;
return 404; # managed by Certbot
}
Locally I don't have such problems, my local config also has try_files $uri =404; row.
What's wrong?
I've tried
location / {
try_files $uri =404;
}
instead
location / {
try_files $uri $uri/ =404;
}
, didn't helped.