[GoRouter & Authentication 마무리하기] 401 에러
해결됨
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
토큰 만료 이후 GoRouter & Authentication 따라할 경우 401 에러를 저도 만났어요. 유사 질문들과 답변이 있어, 저도 경험기 공유합니다. 증상 GoRouter 적용 후 재실행시 Splash 화면에서 무한 로딩 http://127.0.0.1:3000/user/me/ 호출에서 401 로그 확인 원인 refreshToken 이 있거나 accessToken이 있는 경우에 토큰이 만료된 상태이면 증상 발생 의심 해결 user_me_provider.dart 파일 > getMe() 에서 try catch & state 초기화 추가 재실행 Future<void> getMe() async { // ... 중략 try { final resp = await repository.getMe(); state = resp; } catch(e, stack) { print(e); print(stack); state = null; } } 저와 동일한 오류를 만나는 분에게 소소한 도움이 되길 바래요 :)
- flutter
- 401
- gorouter
- authentication
edu.ubiocean
댓글 2
좋아요 4
조회수 933





