Files
harheimertc/server/routes/robots.txt.js
Torsten Schulz (local) 3586704cce
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 10m29s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped
Update file permissions for multiple server and test files to executable mode
2026-07-15 08:45:12 +02:00

31 lines
851 B
JavaScript
Executable File

function normalizeBaseUrl(value) {
const raw = String(value || '').trim()
if (!raw) return ''
return raw.replace(/\/+$/, '')
}
export default defineEventHandler((event) => {
const runtimeConfig = useRuntimeConfig(event)
const requestUrl = getRequestURL(event)
const baseUrl = normalizeBaseUrl(runtimeConfig.public?.baseUrl) || `${requestUrl.protocol}//${requestUrl.host}`
const lines = [
'User-agent: *',
'Allow: /',
'Disallow: /cms',
'Disallow: /cms/',
'Disallow: /mitgliederbereich',
'Disallow: /mitgliederbereich/',
'Disallow: /api/',
'Disallow: /login',
'Disallow: /registrieren',
'Disallow: /passwort-vergessen',
'Disallow: /konto-loeschen',
`Sitemap: ${baseUrl}/sitemap.xml`
]
setHeader(event, 'Content-Type', 'text/plain; charset=utf-8')
return `${lines.join('\n')}\n`
})