fix: 로그인 후 뒤로가기 시 로그인 화면 머무름 방지
- 로그인 페이지에 캐시 금지 헤더(no-store) 추가 → 뒤로가기 시 서버 재요청 - bfcache 복원(pageshow persisted) 시 새로고침 → 로그인 상태면 대시보드로 리다이렉트 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,12 @@ class Auth extends BaseController
|
|||||||
return redirect()->to('/');
|
return redirect()->to('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 로그인 후 뒤로가기 시 브라우저 캐시(bfcache)로 로그인 화면이 다시 보이는 것을 방지.
|
||||||
|
// 캐시 금지 → 뒤로가기 시 서버 재요청 → 로그인 상태면 위에서 대시보드로 리다이렉트.
|
||||||
|
$this->response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
|
||||||
|
$this->response->setHeader('Pragma', 'no-cache');
|
||||||
|
$this->response->setHeader('Expires', '0');
|
||||||
|
|
||||||
return view('auth/login', [
|
return view('auth/login', [
|
||||||
'pageTitle' => '로그인 - GBLS',
|
'pageTitle' => '로그인 - GBLS',
|
||||||
'cardMax' => 'max-w-md',
|
'cardMax' => 'max-w-md',
|
||||||
|
|||||||
@@ -18,4 +18,11 @@
|
|||||||
<a href="<?= base_url('register') ?>" class="bg-white text-gray-700 border border-gray-300 px-4 py-2 rounded-lg text-sm shadow-sm hover:bg-gray-50 transition">회원가입</a>
|
<a href="<?= base_url('register') ?>" class="bg-white text-gray-700 border border-gray-300 px-4 py-2 rounded-lg text-sm shadow-sm hover:bg-gray-50 transition">회원가입</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<script>
|
||||||
|
// 뒤로가기로 bfcache(뒤로/앞으로 캐시)에서 복원된 경우, 서버에 재요청하여
|
||||||
|
// 이미 로그인 상태면 대시보드로 리다이렉트되게 한다.
|
||||||
|
window.addEventListener('pageshow', function (e) {
|
||||||
|
if (e.persisted) { window.location.reload(); }
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user