mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
fix(nuxt): skip router middleware/redirections for islands (#24421)
Co-authored-by: julien huang <julien.huang@outlook.fr>
This commit is contained in:
parent
7c6b6771ab
commit
ec0addd8c8
@ -135,6 +135,11 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
|
||||
await nuxtApp.runWithContext(() => showError(error))
|
||||
}
|
||||
|
||||
if (import.meta.server && nuxtApp.ssrContext?.islandContext) {
|
||||
// We're in an island context, and don't need to handle middleware or redirections
|
||||
return { provide: { router } }
|
||||
}
|
||||
|
||||
const initialLayout = nuxtApp.payload.state._layout
|
||||
router.beforeEach(async (to, from) => {
|
||||
to.meta = reactive(to.meta)
|
||||
@ -200,7 +205,7 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
|
||||
if (import.meta.server && failure?.type === 4 /* ErrorTypes.NAVIGATION_ABORTED */) {
|
||||
return
|
||||
}
|
||||
if (to.matched.length === 0 && (!import.meta.server || !nuxtApp.ssrContext?.islandContext)) {
|
||||
if (to.matched.length === 0) {
|
||||
await nuxtApp.runWithContext(() => showError(createError({
|
||||
statusCode: 404,
|
||||
fatal: false,
|
||||
|
Loading…
Reference in New Issue
Block a user