Notice
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- react native font
- Project
- PongWorld
- React
- 문자열 대소문자
- img upload
- Next.js
- 리액트
- 백준
- AWS Access Key
- babel.config.js
- react native 세팅
- 에러
- error
- react native
- GIT
- react native picker
- 리액트 네이티브 에러
- js
- 리엑트 네이티브 아이콘
- react native 개발
- s3 upload
- firebase 라이브러리
- AWS
- aws bucket 정책
- 리액트 네이티브
- fire base
- react native CLI
- Access Key 생성
- 문자열 대소문자 구별
Archives
- Today
- Total
밝을희 클태
HTTP ERROR 431 : failed to load resource the server responded with a status of 431 () 해결 본문
KEYNUT 프로젝트
HTTP ERROR 431 : failed to load resource the server responded with a status of 431 () 해결
huipark 2024. 7. 8. 14:45
failed to load resource the server responded with a status of 431 ()
프로젝트 진행 도중 갑자기 한 유저로 로그인을 하면 위와 같은 에러가 나고 아예 사이트로 접근이 불가능해졌다.
이 에러가 발생하기 바로 직전 더미 데이터로 테스트를 하려고 MongoDB에 상품 1000개를 넣었다. 그러고 나서 에러가 발생!!
원인 - NextAuth를 사용 중인데 로그인을 할 때 users collection에서 해당 user의 정보를 다 가져와 jwt token에 저장을 한다. 방금 1000개의 더미 데이터를 넣으면서 해당 user의 document에 상품의 ID를 넣는다. 그러면 로그인을 할 때 user document의 data를 다 가져오려하고 데이터가 너무 커서 에러가 발생한다.
async jwt({ token, user, account, trigger, session }) { if (user) { token.user = user; if (user.email === process.env.ADMIN_EMAIL) token.admin = true; } if (account) { token.access_token = account.access_token; token.provider = account.provider; } if (trigger === 'update' && session !== null) { const { openChatUrl, image, nickname, nicknameChangedAt, recentSearches } = session; if (openChatUrl) token.user.openChatUrl = openChatUrl; if (image !== undefined) token.user.image = image; if (nickname) token.user.nickname = nickname; if (nicknameChangedAt) token.user.nicknameChangedAt = nicknameChangedAt; if (recentSearches) token.user.recentSearches = recentSearches; } return token; },
해결 - 다행히 token에서 products 필드는 사용하지 않고 있어서 기존의 user 전체를 저장하는 코드를 products 필드를 빼고 저장
if (user) { delete user.products; token.user = user; if (user.email === process.env.ADMIN_EMAIL) token.admin = true; }
처음 보는 에러라서 처음에 당황했지만 다른 에러들보다 훨씬 해결하기 쉬웠다!!
'KEYNUT 프로젝트' 카테고리의 다른 글
[ JavaScript ] 핀치 줌 구현하기! (0) | 2024.07.19 |
---|---|
[ Next.JS ]상품 업로드, 수정, 조회 로직 (0) | 2024.07.16 |
[ Next.JS ] 효율적인 서버사이드 데이터 캐싱 및 재검증 (0) | 2024.07.13 |
[ Next.JS ] Admin 페이지를 만들어보자 (0) | 2024.07.10 |
cache에 대해서 (0) | 2024.06.30 |