Skip to content

Commit

Permalink
fix(robots): fix host
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Dec 17, 2022
1 parent 991f2e2 commit 369f281
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/routes/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import config from 'nuxt-seo-kit/config'
import { defineEventHandler, setHeader } from 'h3'
import { withBase } from 'ufo'

export default defineEventHandler(async (event) => {
setHeader(event, 'Content-Type', 'text/plain')
const debug = process.dev ? (`# Dev Mode: Generated by nuxt-seo-kit for ${config.hostname}. Indexing is ${config.indexable ? 'allowed' : 'disallowed'}\n`) : ''
return `${debug}User-agent: *\nDisallow: ${config.indexable ? `\nSitemap: ${config.hostname}/sitemap.xml` : '/'}`
return `${debug}User-agent: *\nDisallow: ${config.indexable ? `\n\nSitemap: ${withBase('sitemap.xml', config.hostname)}` : '/'}`
})

0 comments on commit 369f281

Please sign in to comment.