refactor: 로깅 정보 개선-도메인 추가, robots.txt 사이트맵 경로 수정

This commit is contained in:
“hyeonggkim”
2026-03-27 17:59:14 +09:00
parent 2c444a06f3
commit c802c68158
3 changed files with 28 additions and 20 deletions

View File

@@ -11,32 +11,31 @@ type RobotsConfig = {
export default defineEventHandler(async event => {
const host =
(getHeader(event, 'host') || getRequestHost(event)).toString() || ''
const baseDomain = process.env.BASE_DOMAIN || '.onstove.com'
const baseDomain = process.env.BASE_DOMAIN
const isGameAliasExtractable = host.includes(baseDomain)
let gameAlias = ''
if (isGameAliasExtractable) {
gameAlias = host.split('.')[0]
gameAlias = host.split('.')[0].replace(/-dev$/, '')
}
// if (gameAlias && gameAlias !== "www") {
// event.context.gameAlias = gameAlias;
// }
// }
// robots 설정을 직접 가져오기 (미들웨어 context 사용)
let config: RobotsConfig
try {
// robots 설정 추출
const staticUrl = process.env.STATIC_URL
const runType = process.env.RUN_TYPE
// gameAlias가 있을 때만 sitemap 포함
const sitemapUrl = gameAlias
? [`${staticUrl}/${runType}/template/${gameAlias}/sitemap.xml`]
: undefined
config = {
userAgent: '*',
allow: ['/'],
disallow: ['/error', '/inspection/', '/inspection/*', '/html/*'],
sitemap: [
`https://static-pubcomm.gate8.com/local/template/${gameAlias}/sitemap.xml`,
],
host: `${gameAlias}.onstove.com`,
disallow: ['/error', '/inspection/*', '/html/*'],
sitemap: sitemapUrl,
host: gameAlias ? `${gameAlias}.onstove.com` : undefined,
cache: { sMaxAge: 300, staleWhileRevalidate: 600 },
}
} catch (error) {
@@ -46,7 +45,7 @@ export default defineEventHandler(async event => {
config = {
userAgent: '*',
allow: ['/'],
disallow: ['/error', '/inspection/', '/inspection/*', '/html/*'],
disallow: ['/error', '/inspection/*', '/html/*'],
cache: { sMaxAge: 300, staleWhileRevalidate: 600 },
}
}