fix: Service Worker 캐시 오류 및 auth-manager JSON.parse 오류 수정
- sw.js: POST 요청 캐시 시도 차단 (Cache API는 GET만 지원) - sw.js: staleWhileRevalidate에서 response.clone() 타이밍 수정 (body 소비 전에 clone하도록 변경) - sw.js: 캐시 버전 v1.0.3으로 업데이트하여 구버전 캐시 강제 갱신 - auth-manager.js: 쿠키/localStorage에 "undefined" 문자열 저장된 경우 JSON.parse 오류 방지 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,11 +65,14 @@ class AuthManager {
|
||||
*/
|
||||
_getUser() {
|
||||
const ssoUser = this._cookieGet('sso_user') || localStorage.getItem('sso_user');
|
||||
if (ssoUser) {
|
||||
if (ssoUser && ssoUser !== 'undefined' && ssoUser !== 'null') {
|
||||
try { return JSON.parse(ssoUser); } catch(e) {}
|
||||
}
|
||||
const userStr = localStorage.getItem('currentUser');
|
||||
return userStr ? JSON.parse(userStr) : null;
|
||||
if (userStr && userStr !== 'undefined' && userStr !== 'null') {
|
||||
try { return JSON.parse(userStr); } catch(e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* M-Project 작업보고서 시스템
|
||||
*/
|
||||
|
||||
const CACHE_NAME = 'mproject-v1.0.1';
|
||||
const STATIC_CACHE = 'mproject-static-v1.0.1';
|
||||
const DYNAMIC_CACHE = 'mproject-dynamic-v1.0.1';
|
||||
const CACHE_NAME = 'mproject-v1.0.3';
|
||||
const STATIC_CACHE = 'mproject-static-v1.0.3';
|
||||
const DYNAMIC_CACHE = 'mproject-dynamic-v1.0.3';
|
||||
|
||||
// 캐시할 정적 리소스
|
||||
const STATIC_ASSETS = [
|
||||
@@ -113,6 +113,11 @@ self.addEventListener('fetch', (event) => {
|
||||
const { request } = event;
|
||||
const url = new URL(request.url);
|
||||
|
||||
// POST 등 GET 이외 요청은 캐시 불가 → 기본 처리
|
||||
if (request.method !== 'GET') {
|
||||
return;
|
||||
}
|
||||
|
||||
// CORS 요청이나 외부 도메인은 기본 처리
|
||||
if (url.origin !== location.origin && !isCDNResource(url)) {
|
||||
return;
|
||||
@@ -200,10 +205,11 @@ async function staleWhileRevalidate(request) {
|
||||
|
||||
// 백그라운드에서 업데이트
|
||||
const networkResponsePromise = fetch(request)
|
||||
.then((networkResponse) => {
|
||||
.then(async (networkResponse) => {
|
||||
if (networkResponse.ok) {
|
||||
const cache = caches.open(DYNAMIC_CACHE);
|
||||
cache.then(c => c.put(request, networkResponse.clone()));
|
||||
const responseToCache = networkResponse.clone();
|
||||
const cache = await caches.open(DYNAMIC_CACHE);
|
||||
cache.put(request, responseToCache);
|
||||
}
|
||||
return networkResponse;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user