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 a8b3bd4b1a
commit 34fd04bb46
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -308,11 +308,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