swr과 swrConfig를 사용하여 낙관적 업데이트를 하기 위해 키들을 

 

const profileKey = `api/profiles/${article.author.username}`;
const commentsKey = `api/articles/${slug}/comments`;
const articleKey = `api/articles/${slug}`;

 

이렇게 설정해 놨는데

이상하게 요청을 보낼때 

안되어서 확인해보니

앞에 해당 라우트 페이지의 경로가 추가적으로 붙는 거였다

/article/api/articles/article-28-6030

 

그래서 검색해보니

주소를 넣을 때 앞에 /을 붙이지 않으면 상대경로로 인식해 자동으로 해당 라우트를 붙인다고 한다.

그래서 최종적으로

const profileKey = `/api/profiles/${article.author.username}`;
const commentsKey = `/api/articles/${slug}/comments`;
const articleKey = `/api/articles/${slug}`;

이렇게 생성

 

+ Recent posts