Skip to content

Commit

Permalink
Fix : Modify no-cors value
Browse files Browse the repository at this point in the history
- #8
  • Loading branch information
carboxaminoo committed Mar 5, 2024
1 parent a0faeb5 commit c00c622
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 7 additions & 4 deletions mz_v1_front/src/routes/join/+page.svelte
Original file line number Diff line number Diff line change
@@ -61,16 +61,19 @@ async function handleSubmit(event) {
const response = await fetch('http://175.45.194.59:5050/api/v1/users', {
method: 'POST',
body: formData,
mode: 'no-cors',
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
console.log('회원가입 성공:', result);
alert("회원가입 완료했습니다.");
goto('/'); // 성공 시 리디렉션
} else {
alert("회원가입 완료했습니다!!");
goto(targetPath); // 성공 시 리디렉션
} else if (response.status === 409){
alert(`이메일이 중복되었습니다. 다른 이메일을 입력해주세요. `);
}
else {
const error = await response.json();
alert(`회원가입 실패: ${error.message}`);
}
7 changes: 2 additions & 5 deletions mz_v1_front/src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
@@ -21,11 +21,11 @@
const response = await fetch("http://175.45.194.59:5050/api/v1/auth", {
method: 'POST',
body: formData,
mode: 'no-cors',
// mode: 'no-cors',
credentials: 'include',
});
if (response == 200) {
if (response.status === 200) {
const data = await response.json(); // 백엔드로부터 받은 데이터를 JSON으로 파싱
const { token, email } = data; // 파싱된 JSON 객체에서 token과 email을 추출
@@ -35,9 +35,6 @@
goto({targetPath}); // 사용자를 홈 페이지로 리다이렉트
}
else if (response == 409){
alert("이메일이 중복되었습니다.")
}
else {
alert('로그인 실패 \n 이메일과 비밀번호를 확인해주세요');
}}

0 comments on commit c00c622

Please sign in to comment.