according to the official vue instructions, the nginx configuration has been modified to
location / {
try_files $uri $uri/ /index.html;
}
also, if the layout/error.vue, is set in the nuxt project, the result is that the 404 address will display the home page, and the non-404 address will be transferred to the corresponding page.
vue official instructions
404 index.html Vue 404
const router = new VueRouter({
mode: "history",
routes: [
{ path: "*", component: NotFoundComponent }
]
})
I saw the auto-rendered routing of the nuxt project
export function createRouter () {
return new Router({
mode: "history",
base: "/",
linkActiveClass: "nuxt-link-active",
linkExactActiveClass: "nuxt-link-exact-active",
scrollBehavior,
routes: [
{
path: "/product/test",
component: _cda7ca6c,
name: "product-test"
},
{
path: "/product/:id?",
component: _fb3a329c,
name: "product-id"
},
{
path: "/",
component: _776d265b,
name: "index"
}
],
fallback: false
})
}
In the end, does not have a wildcard setting, so it is the cause of the problem. After testing, it is normal to manually modify router and then publish it to nginx, but it is too troublesome. So I"d like to ask you how to solve this problem. Thank you.