Skip to content

Commit 02fa997

Browse files
committed
chore: pass event context for useRuntimeConfig()
1 parent 7a29309 commit 02fa997

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/runtime/server/composables/getPathRobotConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function getPathRobotConfig(e: H3Event, options?: { userAgent?: string, s
8585
}
8686

8787
// 3. nitro route rules
88-
nitroApp._robotsRuleMactcher = nitroApp._robotsRuleMactcher || createNitroRouteRuleMatcher()
88+
nitroApp._robotsRuleMactcher = nitroApp._robotsRuleMactcher || createNitroRouteRuleMatcher(e)
8989
let routeRulesPath = path
9090
// if we're using i18n we need to strip leading prefixes so the rule will match
9191
if (runtimeConfig.public?.i18n?.locales) {

src/runtime/server/kit.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { H3Event } from 'h3'
12
import type { NitroRouteConfig } from 'nitropack'
23
import { defu } from 'defu'
34
import { useRuntimeConfig } from 'nitropack/runtime'
@@ -8,8 +9,8 @@ export function withoutQuery(path: string) {
89
return path.split('?')[0]
910
}
1011

11-
export function createNitroRouteRuleMatcher(): (path: string) => NitroRouteConfig {
12-
const { nitro, app } = useRuntimeConfig()
12+
export function createNitroRouteRuleMatcher(e?: H3Event): (path: string) => NitroRouteConfig {
13+
const { nitro, app } = useRuntimeConfig(e)
1314
const _routeRulesMatcher = toRouteMatcher(
1415
createRadixRouter({
1516
routes: Object.fromEntries(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script lang="ts" setup>
2+
import { defineI18nRoute, defineRouteRules } from '#imports'
3+
4+
defineRouteRules({
5+
robots: false,
6+
})
7+
defineI18nRoute({
8+
paths: {
9+
en: '/other',
10+
fr: '/autre',
11+
},
12+
})
13+
14+
// This is broken
15+
</script>
16+
17+
<template>
18+
<div>route rules custom path</div>
19+
</template>

0 commit comments

Comments
 (0)