fix. robots 수정

This commit is contained in:
“hyeonggkim”
2025-09-18 11:08:24 +09:00
parent 549e4aa364
commit cb4850cf45

View File

@@ -7,16 +7,16 @@ type RobotsConfig = {
host?: string
cache?: { sMaxAge?: number; staleWhileRevalidate?: number }
}
export default defineEventHandler(async (event) => {
const host =
(getHeader(event, "host") || getRequestHost(event)).toString() || "";
const baseDomain = process.env.BASE_DOMAIN || ".onstove.com";
const isGameAliasExtractable = host.includes(baseDomain);
let gameAlias = "";
if (isGameAliasExtractable) {
const gameAlias = host.split(".")[0];
console.log("🚀 ~ 333 gameAlias:", gameAlias)
gameAlias = host.split(".")[0];
}
// if (gameAlias && gameAlias !== "www") {
@@ -28,21 +28,14 @@ type RobotsConfig = {
let config: RobotsConfig;
try {
// 외부 API에서 robots 설정 가져오기
const response = await $fetch('https://static-pubcomm.gate8.com/dev/test0905/dataization/test0905_homepage_brand_siteConfig.json');
// robots 설정 추출
const robotsConfig = response.robots?.rules?.[0] || {
config = {
userAgent: "*",
allow: ["/"],
disallow: ["/error2", "/inspection/", "/inspection/*", "/html/*"]
};
config = {
userAgent: robotsConfig.userAgent,
allow: robotsConfig.allow,
disallow: robotsConfig.disallow,
sitemap: robotsConfig.sitemap,
disallow: ["/error", "/inspection/", "/inspection/*", "/html/*"],
sitemap: [`https://static-pubcomm.gate8.com/local/template/${gameAlias}/sitemap.xml`],
host: `${gameAlias}.onstove.com`,
cache: { sMaxAge: 300, staleWhileRevalidate: 600 }
};
} catch (error) {
@@ -53,8 +46,6 @@ type RobotsConfig = {
userAgent: "*",
allow: ["/"],
disallow: ["/error", "/inspection/", "/inspection/*", "/html/*"],
sitemap: ["https://l922.onstove.com/sitemap.xml"],
host: "epic7.onstove.com",
cache: { sMaxAge: 300, staleWhileRevalidate: 600 }
};
}