회원가입 500 에러 (Internal Server Error)
1468
작성한 질문수 9
회원가입을 시도할 경우 500 에러가 납니다.
const onSubmit = useCallback(
(e) => {
e.preventDefault();
// console.log(email, nickname, password, passwordCheck);
if (!mismatchError) {
console.log('서버로 회원가입하기');
setSignUpError('');
setSignUpSuccess(false);
axios
.post('/api/users', { email, nickname, password })
.then((response) => {
console.log(response);
setSignUpSuccess(true);
})
.catch((error) => {
console.log(error.response);
setSignUpError(error.response.data);
})
.finally(() => {});
}
},
[email, nickname, password, passwordCheck, mismatchError],
);
개발자 도구의 network 탭을 보니 아예 요청이 가지 않는것 같습니다. 어디서 문제인걸까요..?
답변 1
0
요청은 갔을 겁니다. 다만 네트워크탭을 늦게 여셨을 겁니다. 백엔드 서버쪽에 에러메시지가 있을 겁니다.
0
POST /api/users 500 27.590 ms - 1460
Error: secret option required for sessions
at session (C:\Users\user\Desktop\coding\sleact\server\node_modules\express-session\index.js:200:12)
at Layer.handle [as handle_request] (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:317:13)
at C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:275:10)
at cookieParser (C:\Users\user\Desktop\coding\sleact\server\node_modules\cookie-parser\index.js:57:14)
at Layer.handle [as handle_request] (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:317:13)
at C:\Users\user\Desktop\coding\sleact\server\node_modules\express\lib\router\index.js:284:7
말씀주신대로 네트워크 탭에서 요청 가진거는 다시 한번 확인했습니다.
위에 코드는 서버 에러입니다! 혹시 .env 파일 문제일까요??? MYSQL_PASSWORD도 .env 파일에 잘 명시해뒀는데 적용이 안되어서 server/config/config.js 파일에 직접 문자열로 넣어줬었습니다.


0
저 에러는 process.env.COOKIE_SECRET이 express-session에 들어가지 않았을 때 발생하는 에러입니다.
.env가 인식이 안 되었으면 express-session에도 직접 적으셔야겠습니다.
기본 셋팅과 관련하여
0
91
1
초기 셋팅 back과 front만 남겨두고 다 지운 후 진행 방법
0
96
2
focus 시에만 화면 업데이트 되는 이유 + 해결방법
0
149
2
useEffect 개수 관리
0
109
2
라이브러리 서치 방법
0
103
2
함수 정의 패턴
0
77
1
npm run dev 에러
0
152
3
npx webpack 후 에러
0
178
2
'void' 형식 식의 truthiness를 테스트할 수 없습니다.ts(1345)
0
143
2
사용자 가입시 에러발생 (TypeError: Cannot read properties of null (reading 'addMembers')
1
177
2
초기세팅중 packge.json 에러떠요
0
154
2
CORS - Access-Control-Allow-Origin 누락 문제
0
430
3
로그인 페이지 무한 새로고침 현상
0
598
2
Module not found: Error: Can't resolve './App' 에러
0
954
1
배포 방법
0
296
2
npm run dev 시 빌드가 매우 느려졌습니다
0
989
2
alias 경로 설정 오류
0
448
2
fetcher 함수의 data 값이 두번 찍히는 이유
0
275
1
제네릭 질문
0
217
2
ts-node 대신 tsx 사용여부
0
373
1
배포 관련 질문
0
247
1
[nginx + https] 서비스를 실행하면 niginx가 아닌 서비스 화면을 보여주게 하고 싶습니다.
0
385
2
[배포하기] webpack에 aws 퍼블릭 IPv4 주소 와 포트 주소를 작성하고 나서 빌드후 실행하면 오류가 발생합니다.
0
336
1
users 호출 시 쿠키가 담기지 않는 이슈 질문드립니다.
0
247
2





