Philipp S.
Philipp S.

Reputation: 981

Nuxt-Router: Slug in URL should not be optional

My directory structure looks like that /pages/request/guest/_slug/index.vue

If I call /request/guest/test-slug/ then Nuxt opens the index.vue file as expected.

But /request/guest/ without a slug also opens the same index.vue file.

Why is that? It should return an 404.

Upvotes: 0

Views: 2151

Answers (1)

arman amraei
arman amraei

Reputation: 195

in index.vue you should check for route params and if there is no slug then return an error . You can use validate props in your _slug/index.vue file to check if route.params.slug exists. https://nuxtjs.org/api/pages-validate

otherwise it just show the index.vue

Upvotes: 1

Related Questions