- 모바일 웹에서 옛 index.html 캐시가 삭제된 옛 청크를 불러 메뉴(가계부 내역 등)가 안 열리는 문제 → router.onError 로 청크 실패 감지 시 목적지로 전체 새로고침 - nginx 설정에 index.html no-cache 추가(재발 방지) — 서버 적용 필요 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -107,4 +107,16 @@ router.beforeEach((to, from) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 새 배포로 청크 해시가 바뀐 뒤, 캐시된 옛 index.html 이 삭제된 옛 청크를 부르면
|
||||
// 동적 import 가 실패한다. 이 경우 목적지로 전체 새로고침해 최신 index.html 을 받게 한다.
|
||||
let reloadingForChunk = false
|
||||
router.onError((err, to) => {
|
||||
const msg = (err && err.message) || ''
|
||||
const chunkError = /dynamically imported module|Importing a module script failed|Failed to fetch dynamically imported module|ChunkLoadError|error loading dynamically imported module/i.test(msg)
|
||||
if (chunkError && !reloadingForChunk) {
|
||||
reloadingForChunk = true
|
||||
window.location.assign(to?.fullPath || window.location.pathname)
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user