mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
fix(nuxt): handle external redirects from routeRules
(#26120)
This commit is contained in:
parent
7551e440e0
commit
e9082ad28e
@ -1,3 +1,4 @@
|
||||
import { hasProtocol } from 'ufo'
|
||||
import { defineNuxtRouteMiddleware } from '../composables/router'
|
||||
import { getRouteRules } from '../composables/manifest'
|
||||
|
||||
@ -5,6 +6,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
||||
if (import.meta.server || import.meta.test) { return }
|
||||
const rules = await getRouteRules(to.path)
|
||||
if (rules.redirect) {
|
||||
if (hasProtocol(rules.redirect, { acceptRelative: true })) {
|
||||
window.location.href = rules.redirect
|
||||
return false
|
||||
}
|
||||
return rules.redirect
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user