

원인 : Nextjs에서 SSR을 할 때 처음 렌더링하는 과정에서 window나 document 전역 객체가 존재하지 않는다.
해결방법 : typeof window !== undefined일 때 해당 소스코드가 실행되게 한다
const saveUrl = new Promise((resolve, reject) => {
if (typeof window !== undefined) {
const url = window.document.location.href;
resolve(url);
}
});
출처 : https://handhand.tistory.com/272