Skip to content

Commit 1cc6ac4

Browse files
authoredOct 29, 2024··
fix: support missing runtimeConfig (#155)
1 parent d97726b commit 1cc6ac4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

Diff for: ‎src/runtime/nitro/server/middleware.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ export default defineEventHandler(async (e) => {
66
if (e.path === '/robots.txt' || e.path.startsWith('/__') || e.path.startsWith('/api') || e.path.startsWith('/_nuxt'))
77
return
88
const robotConfig = getPathRobotConfig(e)
9-
const { header } = useRuntimeConfig(e)['nuxt-robots']
10-
if (header) {
11-
setHeader(e, 'X-Robots-Tag', robotConfig.rule)
9+
const nuxtRobotsConfig = useRuntimeConfig(e)['nuxt-robots']
10+
if (nuxtRobotsConfig) {
11+
const { header } = nuxtRobotsConfig
12+
if (header) {
13+
setHeader(e, 'X-Robots-Tag', robotConfig.rule)
14+
}
15+
e.context.robots = robotConfig
1216
}
13-
e.context.robots = robotConfig
1417
})

0 commit comments

Comments
 (0)
Please sign in to comment.