fix. /home으로 리다이렉트 처리 되도록 수정, csr에서 이동되어 하이드레이션 나던 부분 수정

This commit is contained in:
clkim
2025-11-19 16:18:53 +09:00
parent 1596f874ff
commit 26780143d1
3 changed files with 48 additions and 23 deletions

View File

@@ -414,6 +414,28 @@ export default defineEventHandler(async event => {
}
}
}
// -------------------------------------------------------------------------------
// [Root Path Redirect to /home]
// 언어 코드만 있는 경로(예: /ko, /ko/)를 /home 리다이렉트
// -------------------------------------------------------------------------------
const normalizedPath = fullPath.endsWith('/')
? fullPath.slice(0, -1)
: fullPath
const localePath = `/${finalLocale}`
if (normalizedPath === localePath) {
const defaultPath = `/${finalLocale}/home`
const queryString = event?.node.req.url?.includes('?')
? '?' + event.node.req.url.split('?')[1]
: ''
if (!event.node.res.headersSent && !event.node.res.writableEnded) {
event.node.res.statusCode = 302
event.node.res.setHeader('Location', defaultPath + queryString)
event.node.res.end()
return
}
}
// -------------------------------------------------------------------------------
// [Locale Middleware]
// -------------------------------------------------------------------------------