NextJS + Firebase + Serverless (AWS Lambda) 사용기

버들비·2020년 12월 6일
0

몇가지 삽질 기록


원래 설계

NextJS 의 getServerSideProps 에서 firebase.firestore 를 호출, firestore 데이터베이스에서 자료를 불러온 뒤 클라이언트쪽 코드에 props 로 넘긴다.
배포는 serverless로.

serverless 로 배포하니 문제 발생

aws lambda가 오류를 뱉는다.
getServerSideProps 에서 firestore 함수를 사용하는게 문제인듯.
firestore 함수들을 클라이언트 쪽으로 옮겨주니 (useEffect 내부에 집어넣어서 초기 렌더링때 데이터를 불러오니) 문제가 사라졌다.


NextJS에서 components 폴더의 위치 문제.

components 폴더를 pages 폴더 하위에 집어넣었더니, 클라어인트에서 컴포넌트를 dynamic import 해도 ssr 처리를 해버리는듯. window not defined 오류를 내뱉는다.
components 폴더를 루트 디렉토리로 옮기니 문제 해결.

0개의 댓글