Skip to content

Commit 02c4db2

Browse files
committed
feat: Force redirect when web response URL is not matching current route path
1 parent 0b48813 commit 02c4db2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pages/[...slug].vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
<script setup lang="ts"></script>
1+
<script setup lang="ts">
2+
// definePageMeta({
3+
// pageTransition: defaultPageTransition,
4+
// })
5+
6+
import type { RoadizNodesSources } from '@roadiz/types'
7+
8+
const { item, error } = await useRoadizWebResponse<RoadizNodesSources>()
9+
10+
if (error) {
11+
showError(error)
12+
}
13+
14+
const route = useRoute()
15+
// Force redirect when web response URL is not matching current route path
16+
if (item?.url && item.url !== route.path) {
17+
await navigateTo({ path: item?.url }, { redirectCode: 301 })
18+
}
19+
</script>
220

321
<template>
422
<div>Hello world</div>

0 commit comments

Comments
 (0)