Skip to content
Discussion options

You must be logged in to vote

해당 에러의 원인은 전역 상태의 초기화가 제대로 일어나지 않아서로 밝혀졌습니다.
(RecoilRoot 에서 에러가 발생하는 경우)

app.tsx에서 서버 사이드에서 내 정보를 받아온 후,
RecoilRootinitialState에서 직접 userAtom을 초기화하여 해결할 수 있습니다.

서버 사이드에서 서버사이드 쿠키를 이용하여 데이터 받아오기

ArtZip.getInitialProps = async (appContext: AppContext) => {
  const appProps = await App.getInitialProps(appContext);
  // 서버 사이드 쿠키 얻어오기
  const { ctx } = appContext;
  const allCookies = cookies(ctx);

  const accessToken = allCookies['ACCESS_TOKEN'];
  const refreshToken = allCookies['REFRESH_TOKEN'];

  let userState = SIGNOUT_USER_STATE;

  if (refreshToken && accessToken) {
    try {
      const { isAuth, data } = await authorizeFetch({
        accessToken,
        refreshToken,

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@punchdrunkard
Comment options

punchdrunkard Aug 12, 2022
Maintainer Author

Comment options

You must be logged in to vote
1 reply
@punchdrunkard
Comment options

punchdrunkard Oct 2, 2022
Maintainer Author

Answer selected by punchdrunkard
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment