feat: 언어 변경 추가

This commit is contained in:
“hyeonggkim”
2025-09-19 19:11:01 +09:00
parent ce08a58118
commit 2ea8b69f7b
10 changed files with 238 additions and 32 deletions

View File

@@ -5,6 +5,8 @@ import {
getRequestURL,
} from 'h3'
import { ssrGetFinalLocale } from '../../utils/localeUtil'
export default defineEventHandler(async event => {
const url = getRequestURL(event)
@@ -25,7 +27,7 @@ export default defineEventHandler(async event => {
const isGameAliasExtractable = host.includes(baseDomain)
if (isGameAliasExtractable) {
const gameAlias = host.split('.')[0]
const gameAlias = host.split(':')[0]
if (gameAlias && gameAlias !== 'www') {
event.context.gameAlias = gameAlias
@@ -38,21 +40,23 @@ export default defineEventHandler(async event => {
const stoveApiBaseUrl = config.public.stoveApiUrl
const apiUrl = `${stoveApiBaseUrl}/pub-comm/v1.0/template/game`
const langCode = ssrGetFinalLocale(event?.node.req.url, event.node.req.headers)
// URL의 첫 번째 path를 lang_code로 사용 (파비콘, API 경로 제외)
const url = getRequestURL(event)
const pathSegments = url.pathname
.split('/')
.filter(
segment =>
segment &&
!segment.includes('favicon') &&
!segment.includes('api') &&
!segment.startsWith('_')
)
const langCode = pathSegments[0] || 'ko'
// const pathSegments = url.pathname
// .split('/')
// .filter(
// segment =>
// segment &&
// !segment.includes('favicon') &&
// !segment.includes('api') &&
// !segment.startsWith('_')
// )
// const langCode = pathSegments[0] || 'ko'
const queryParams: Record<string, string> = {
game_alias: event.context.gameAlias || '',
game_domain: event.context.gameAlias || '',
lang_code: langCode,
}