https://codesandbox.io/s/nuxt-trailingslash-false-and-child-routes-3etm9?file=/pages/posts.vue
Nuxt configuration
router: {
trailingSlash: false
},
Routes configuration
routes: [{
path: "/posts",
component: _ad4aa402,
pathToRegexpOptions: {"strict":true},
children: [{
path: "",
component: _19067942,
pathToRegexpOptions: {"strict":true},
name: "posts"
}, {
path: ":slug?",
component: _174fd7fa,
pathToRegexpOptions: {"strict":true},
name: "posts-slug"
}]
}, {
path: "/",
component: _00cac37e,
pathToRegexpOptions: {"strict":true},
name: "index"
}],
fallback: false
}
Directory structure:

With a directory structure like pictured above (where the posts.vue parent route contains <router-view>), navigate to both /posts and /posts/.
I'm not sure but possibly the opposite of what is happening right now.
/posts loads the posts/_slug child route./posts/ loads the posts/index child route.Results for the previous version of Nuxt (2.13.3):
Routes configuration
routes: [{
path: "/posts",
component: _ad4aa402,
pathToRegexpOptions: {"strict":true},
name: "posts",
children: [{
path: "",
component: _19067942,
pathToRegexpOptions: {"strict":true},
name: "posts"
}, {
path: ":slug",
component: _174fd7fa,
pathToRegexpOptions: {"strict":true},
name: "posts-slug"
}]
}, {
path: "/",
component: _00cac37e,
pathToRegexpOptions: {"strict":true},
name: "index"
}],
fallback: false
}
Notice that in the new version of Nuxt the _slug route has :slug? path while in the older version it has :slug. This is probably related to the parent route no longer having a name (which is likely the right thing to do).
@manniL What do you think is expected here regarding the child _slug route being optional? Since there is an index route besides it, I would think that it shouldn't be optional.
This also seems related to #7843 so CC'ing @farnabaz
So, with trailingSlash being false, I'd expect to have /posts to show the index page while /posts/ shouldn't show any and return a 404. /posts/foo should then show the _slug.vue content while /posts/foo/ should return a 404.
@farnabaz since you've done some related changes, do you want to tackle this too? :)
Or do you have an opinion at least and does it match with @manniL 's?
@manniL Take a look at https://github.com/nuxt/nuxt.js/pull/6594/files#diff-1288a325a940f45fdc5707e5485c442aR75
When we replace defaultChildRoute.name with parent's name, we remove -index from defaultChildRoute.name.
By removing -index from defaultChildRoute.name, :slug in the other child will become optional and it causes the issue.
In nuxt-edge trailingSlash: false, results in $route.name to be undefined when using nuxt-child and going to /parent expect it to be parent-index.
I think this is the same issue
So, with
trailingSlashbeingfalse, I'd expect to have/poststo show the index page while/posts/shouldn't show any and return a 404./posts/fooshould then show the_slug.vuecontent while/posts/foo/should return a 404.
@manniL this would be the ideal solution.
I'm not updating Nuxt dependency in nuxt-i18n until this is fixed. :P
Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:
Issues that are labeled as pending will not be automatically marked as stale.
..
Bump, any updates/progress?
This should be fixed in v2.14.8. Please reopen if not.
There is still an issue with trailingSlash: true but I'll create a separate issue for that.
New issue: #8422
Most helpful comment
I'm not updating Nuxt dependency in
nuxt-i18nuntil this is fixed. :P