Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piroinfront",
"proxy": "http://localhost:8080",
"proxy": "http://13.209.73.127:8080",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/login/LoginPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { authFetch } from '../../utils/Api';
import styles from './LoginPage.module.css';

Expand All @@ -16,21 +16,25 @@ function LoginPage() {

const handleLogin = async () => {
try {
const response = await authFetch('/api/auth/login', {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(form),
});

if (response.ok) {
const data = await response.json();
console.log('로그인 응답:', data);
localStorage.setItem('token', data.token);
localStorage.setItem('role', data.role);
navigate('/sessions'); // 로그인 성공 시 이동할 페이지
} else {
const errData = await response.json();
console.log('로그인 실패 응답:', errData);
alert('이름 또는 비밀번호가 올바르지 않습니다.');
}
} catch (error) {
console.log('catch 에러:', error);
alert('서버 오류가 발생했습니다.');
}
};
Expand Down
Loading