fix(nuxt): prevent 404 when hitting component test endpoint

This commit is contained in:
Daniel Roe 2024-10-08 20:33:19 +02:00
parent 613340edcf
commit cb725f0146
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -409,8 +409,18 @@ export default defineNuxtModule({
})
}
if (nuxt.options.experimental.appManifest) {
const componentStubPath = await resolvePath(resolve(runtimeDir, 'component-stub'))
if (nuxt.options.test && nuxt.options.dev) {
// add component testing route so 404 won't be triggered
nuxt.hook('pages:extend', (routes) => {
routes.push({
_sync: true,
path: '/__nuxt_component_test__/:pathMatch(.*)',
file: componentStubPath,
})
})
}
if (nuxt.options.experimental.appManifest) {
// Add all redirect paths as valid routes to router; we will handle these in a client-side middleware
// when the app manifest is enabled.
nuxt.hook('pages:extend', (routes) => {