Skip to content

Commit

Permalink
fix: redirect with nuxt context when is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
mercs600 committed Mar 21, 2024
1 parent c90eb2d commit daa3b80
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/runtime/composables/useT3Utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cleanDoubleSlashes } from 'ufo'
import { cleanDoubleSlashes, hasProtocol } from 'ufo'
import { navigateTo, useNuxtApp } from '#app'
import type { T3RedirectData } from '../../types'
import { useT3i18nState } from './useT3i18n'
Expand All @@ -18,11 +18,12 @@ export const useT3Utils = () => {
const redirect = async (redirectData: T3RedirectData) => {
await nuxtApp.callHook('t3:redirect', redirectData)
const { redirectUrl, statusCode } = redirectData
const isExternal = hasProtocol(redirectUrl, { acceptRelative: true })

return navigateTo(redirectUrl, {
return await nuxtApp.runWithContext(() => navigateTo(redirectUrl, {
redirectCode: statusCode,
external: true
})
external: isExternal
}))
}

/**
Expand Down

0 comments on commit daa3b80

Please sign in to comment.