fix(nuxt): add / as fallback if page can't be identified

This commit is contained in:
Daniel Roe 2024-07-03 12:09:11 +01:00
parent 809fb71ca5
commit e6109b2266
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -303,11 +303,9 @@ export default defineNuxtModule({
// Only hint the first route when `ssr: true` and no routes are provided
if (nuxt.options.ssr) {
nitro.hooks.hook('prerender:routes', (routes) => {
if ([...routes].every(r => r.endsWith('.html'))) {
if ([...routes].every(r => r.match(/(^\/api|\.\w+)/))) {
const [firstPage] = [...prerenderRoutes].sort()
if (firstPage) {
routes.add(firstPage)
}
routes.add(firstPage || '/')
}
})
return