Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9082ad

Browse files
authored
fix(nuxt): handle external redirects from routeRules (#26120)
1 parent 7551e44 commit e9082ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import { hasProtocol } from 'ufo'
12
import { defineNuxtRouteMiddleware } from '../composables/router'
23
import { getRouteRules } from '../composables/manifest'
34

45
export default defineNuxtRouteMiddleware(async (to) => {
56
if (import.meta.server || import.meta.test) { return }
67
const rules = await getRouteRules(to.path)
78
if (rules.redirect) {
9+
if (hasProtocol(rules.redirect, { acceptRelative: true })) {
10+
window.location.href = rules.redirect
11+
return false
12+
}
813
return rules.redirect
914
}
1015
})

0 commit comments

Comments
 (0)