Skip to content

Commit

Permalink
fix(nuxt): prevent 404 when hitting component test endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 9, 2024
1 parent 613340e commit cb725f0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/nuxt/src/pages/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,18 @@ export default defineNuxtModule({
})
}

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) {
const componentStubPath = await resolvePath(resolve(runtimeDir, 'component-stub'))
// 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) => {
Expand Down

0 comments on commit cb725f0

Please sign in to comment.