Skip to content

Commit

Permalink
fix: support missing runtimeConfig (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoujiSano authored Oct 29, 2024
1 parent d97726b commit 1cc6ac4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/runtime/nitro/server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export default defineEventHandler(async (e) => {
if (e.path === '/robots.txt' || e.path.startsWith('/__') || e.path.startsWith('/api') || e.path.startsWith('/_nuxt'))
return
const robotConfig = getPathRobotConfig(e)
const { header } = useRuntimeConfig(e)['nuxt-robots']
if (header) {
setHeader(e, 'X-Robots-Tag', robotConfig.rule)
const nuxtRobotsConfig = useRuntimeConfig(e)['nuxt-robots']
if (nuxtRobotsConfig) {
const { header } = nuxtRobotsConfig
if (header) {
setHeader(e, 'X-Robots-Tag', robotConfig.rule)
}
e.context.robots = robotConfig
}
e.context.robots = robotConfig
})

0 comments on commit 1cc6ac4

Please sign in to comment.