🚨 에러 해결
[Next + Supabase] 2개의 supabase 클라이언트
마스터뢕트
2024. 10. 22. 09:04
🚨 에러
You're importing a component that needs next/headers. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/
│ react-essentials#server-components
💡 원인
supabase를 Next.js에서 사용할 때 2개의 supabase client를 설정해놓는다. 하나는 클라이언트 환경(브라우저)에서 사용, 또 다른 하나는 서버 환경에서 사용한다. 근데 서버용 supabase client를 클라이언트 환경에서 사용하려하니 난 에러이다.
📍 해결
서버 액션 파일 상단에 "use server"지시어를 입력하고 바로 해결 되었다.