next.js의 server actions을 통해 응답을 줄 때 next에 내장되어 있는 http status code로 네트워크 응답이 내려가는데, 이 부분이 프레임워크에서 알아서 처리해주고 있는데 이걸 나중에 제어할 필요가 생기면 어떻게 해야 하는건지? 라는 의문이 있음 🤔
예를 들어 /app/login/actions.ts 에서 login 이라는 서버 액션 함수를 통해 로그인 처리를 해줄 때 유효성 검사를 통과해 result.success 분기를 타서 로그인 성공 처리를 해줌. 이때 iron-session을 이용해 handleLogin 처리 후, redirect를 해주기 때문에 개발자 도구 네트워크 탭을 확인해 보면 POST /login에 대한 status code가 303 See Others 임
(로그아웃 처리도 마찬가지. )
유효성 검사를 통과하지 못해, 즉 !result.success 분기를 타서 return result.error.flatten()을 리턴하는 경우 200 OK 임
PrismaClientInitializationError: Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client because Prisma's auto-generation isn't triggered. To fix this, make sure to run the prisma generate command during the build process.
주요 변경 사항
prisma
설치iron-session
을 사용하여 로그인 처리어려운 점
next.js의 server actions을 통해 응답을 줄 때 next에 내장되어 있는 http status code로 네트워크 응답이 내려가는데, 이 부분이 프레임워크에서 알아서 처리해주고 있는데 이걸 나중에 제어할 필요가 생기면 어떻게 해야 하는건지? 라는 의문이 있음 🤔
예를 들어 /app/login/actions.ts 에서
login
이라는 서버 액션 함수를 통해 로그인 처리를 해줄 때 유효성 검사를 통과해result.success
분기를 타서 로그인 성공 처리를 해줌. 이때iron-session
을 이용해 handleLogin 처리 후, redirect를 해주기 때문에 개발자 도구 네트워크 탭을 확인해 보면POST /login
에 대한 status code가 303 See Others 임(로그아웃 처리도 마찬가지. )
유효성 검사를 통과하지 못해, 즉
!result.success
분기를 타서return result.error.flatten()
을 리턴하는 경우 200 OK 임수정 완료
commit
0cbfc47 https://pris.ly/d/vercel-build