diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/back/app.js b/back/app.js index a5e9e50..e254aa7 100644 --- a/back/app.js +++ b/back/app.js @@ -22,7 +22,7 @@ const app = express(); // credentials: true // })); app.use(cors({ - origin: 'http://localhost:3000', // 프론트 주소 + origin: 'https://star-client-brown.vercel.app', // 프론트 주소 methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization'], credentials: true diff --git a/front/.gitignore b/front/.gitignore index 4d29575..966bc27 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -21,3 +21,4 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +.env \ No newline at end of file diff --git a/front/src/api/axios.js b/front/src/api/axios.js index 36869b6..23df202 100644 --- a/front/src/api/axios.js +++ b/front/src/api/axios.js @@ -1,7 +1,7 @@ import axios from 'axios'; const instance = axios.create({ - baseURL: 'http://localhost:8080/api', // 변경 시 여기만 수정 + baseURL: 'https://star-isih.onrender.com', // 변경 시 여기만 수정 withCredentials: true }); diff --git a/front/src/pages/HotspotPage.js b/front/src/pages/HotspotPage.js index 15f6fdb..6bb39d3 100644 --- a/front/src/pages/HotspotPage.js +++ b/front/src/pages/HotspotPage.js @@ -31,16 +31,16 @@ const HotspotPage = () => { try { let response; if (category === 'Auditorium Size / Large Hall') { - response = await axios.get('http://localhost:8080/api/analytics/popular-buildings/by-large-group'); + response = await axios.get('https://star-isih.onrender.com/api/analytics/popular-buildings/by-large-group'); } else if (category === 'Study Friendly') { - response = await axios.get('http://localhost:8080/api/analytics/popular-buildings/by-purpose?purpose=Study'); + response = await axios.get('https://star-isih.onrender.com/api/analytics/popular-buildings/by-purpose?purpose=Study'); } else if (category === 'Meeting & Presentation / Collab Zones') { - response = await axios.get('http://localhost:8080/api/analytics/popular-buildings/by-purpose?purpose=Meeting'); + response = await axios.get('https://star-isih.onrender.com/api/analytics/popular-buildings/by-purpose?purpose=Meeting'); } const hotspotData = Array.isArray(response.data) ? response.data : [response.data]; - const allBuildingsRes = await axios.get('http://localhost:8080/api/buildings'); + const allBuildingsRes = await axios.get('https://star-isih.onrender.com/api/buildings'); const allBuildings = allBuildingsRes.data.buildings; const matched = hotspotData.map((item, i) => { @@ -87,7 +87,7 @@ const HotspotPage = () => { const handleReserve = async (building) => { try { - const res = await axios.get(`http://localhost:8080/api/buildings/rooms?buildingNo=${building.id}`); + const res = await axios.get(`https://star-isih.onrender.com/api/buildings/rooms?buildingNo=${building.id}`); const availableRooms = res.data.rooms.map(room => ({ room: `Room ${room}`, time: '8:00 - 17:50', diff --git a/front/src/pages/LoginPage.js b/front/src/pages/LoginPage.js index 7d1f69e..c5dbeb8 100644 --- a/front/src/pages/LoginPage.js +++ b/front/src/pages/LoginPage.js @@ -17,7 +17,7 @@ const LoginPage = () => { const handleLogin = async () => { try { - const res = await axios.post('http://localhost:8080/api/users/login', form); + const res = await axios.post('https://star-isih.onrender.com/api/users/login', form); localStorage.setItem('token', res.data.token); localStorage.setItem('user', JSON.stringify(res.data.user)); navigate('/'); // ✅ 메인 페이지로 이동 diff --git a/front/src/pages/MyReservationPage.js b/front/src/pages/MyReservationPage.js index 747eac3..22fc0fa 100644 --- a/front/src/pages/MyReservationPage.js +++ b/front/src/pages/MyReservationPage.js @@ -24,7 +24,7 @@ const MyReservationPage = () => { // 🧭 건물 리스트 받아오기 const fetchBuildings = async () => { try { - const res = await axios.get('http://localhost:8080/api/buildings'); + const res = await axios.get('https://star-isih.onrender.com/api/buildings'); setBuildings(res.data.buildings || []); } catch (err) { console.warn('⚠️ 건물 정보 fetch 실패, fallback mock 사용'); @@ -39,7 +39,7 @@ const MyReservationPage = () => { const fetchReservations = async () => { try { const token = localStorage.getItem('token'); - const res = await axios.get('http://localhost:8080/api/reservations/my', { + const res = await axios.get('https://star-isih.onrender.com/api/reservations/my', { headers: { Authorization: `Bearer ${token}` } }); setReservations(res.data); @@ -85,7 +85,7 @@ const MyReservationPage = () => { const confirmCancel = async () => { try { const token = localStorage.getItem('token'); - await axios.delete(`http://localhost:8080/api/reservations/${selectedReservation._id}`, { + await axios.delete(`https://star-isih.onrender.com/api/reservations/${selectedReservation._id}`, { headers: { Authorization: `Bearer ${token}` } }); setReservations(reservations.filter(r => r._id !== selectedReservation._id)); diff --git a/front/src/pages/ProfilePage.js b/front/src/pages/ProfilePage.js index 22350ff..6603781 100644 --- a/front/src/pages/ProfilePage.js +++ b/front/src/pages/ProfilePage.js @@ -58,23 +58,23 @@ const ProfilePage = () => { const token = localStorage.getItem('token'); if (!token) throw new Error('No token'); - const res = await axios.get('http://localhost:8080/api/users/me', { + const res = await axios.get('https://star-isih.onrender.com/api/users/me', { headers: { Authorization: `Bearer ${token}` } }); const userData = res.data.user; setUser(userData); - // ✅ 서버에서 전체 건물 목록 받아오기 - const buildingsRes = await axios.get('http://localhost:8080/api/buildings'); + // 서버에서 전체 건물 목록 받아오기 + const buildingsRes = await axios.get('hhttps://star-isih.onrender.com/api/buildings'); const buildingData = buildingsRes.data.buildings; - // ✅ building.name과 userData.favorites를 비교해 매칭 + // building.name과 userData.favorites를 비교해 매칭 const matched = await Promise.all( buildingData .filter(b => userData.favorites.includes(b.buildingName)) .map(async (b) => { - const roomRes = await axios.get(`http://localhost:8080/api/buildings/rooms?buildingNo=${b.buildingNo}`); + const roomRes = await axios.get(`https://star-isih.onrender.com/api/buildings/rooms?buildingNo=${b.buildingNo}`); const availableRooms = roomRes.data.rooms || []; return { @@ -123,13 +123,13 @@ const ProfilePage = () => { if (token) { if (isAlreadyFavorite) { - await axios.delete('http://localhost:8080/api/users/favorites', { + await axios.delete('https://star-isih.onrender.com/api/users/favorites', { headers: { Authorization: `Bearer ${token}` }, data: { building: buildingName }, }); updatedFavorites = user.favorites.filter((n) => n !== buildingName); } else { - await axios.post('http://localhost:8080/api/users/favorites', { building: buildingName }, { + await axios.post('https://star-isih.onrender.com/api/users/favorites', { building: buildingName }, { headers: { Authorization: `Bearer ${token}` }, }); updatedFavorites = [...user.favorites, buildingName]; diff --git a/front/src/pages/ReservePage.js b/front/src/pages/ReservePage.js index 8e1b002..57824a1 100644 --- a/front/src/pages/ReservePage.js +++ b/front/src/pages/ReservePage.js @@ -54,8 +54,8 @@ const ReservePage = () => { try { const token = localStorage.getItem('token'); const [buildingsRes, userRes] = await Promise.all([ - axios.get('http://localhost:8080/api/buildings'), - axios.get('http://localhost:8080/api/users/me', { + axios.get('https://star-isih.onrender.com/api/buildings'), + axios.get('https://star-isih.onrender.com/api/users/me', { headers: { Authorization: `Bearer ${token}` } }), ]); @@ -65,7 +65,7 @@ const ReservePage = () => { const buildingList = await Promise.all( buildingData.map(async (b) => { - const roomRes = await axios.get(`http://localhost:8080/api/buildings/rooms?buildingNo=${b.buildingNo}`); + const roomRes = await axios.get(`https://star-isih.onrender.com/api/buildings/rooms?buildingNo=${b.buildingNo}`); const availableRooms = roomRes.data.rooms || []; return { id: String(b.buildingNo), @@ -99,7 +99,7 @@ const ReservePage = () => { try { if (isAlreadyFavorite) { - await axios.delete('http://localhost:8080/api/users/favorites', { + await axios.delete('https://star-isih.onrender.com/api/users/favorites', { headers: { Authorization: `Bearer ${token}` }, data: { building: buildingName }, }); @@ -107,7 +107,7 @@ const ReservePage = () => { setFavoriteIds(updated); localStorage.setItem('favorites', JSON.stringify(updated)); } else { - await axios.post('http://localhost:8080/api/users/favorites', { building: buildingName }, { + await axios.post('https://star-isih.onrender.com/api/users/favorites', { building: buildingName }, { headers: { Authorization: `Bearer ${token}` }, }); const updated = [...favoriteIds, buildingName]; diff --git a/front/src/pages/RoomDetailPage.js b/front/src/pages/RoomDetailPage.js index 1b20629..7c8f184 100644 --- a/front/src/pages/RoomDetailPage.js +++ b/front/src/pages/RoomDetailPage.js @@ -84,7 +84,7 @@ const RoomDetailPage = () => { const fetchAvailability = async () => { try { - const res = await axios.get('http://localhost:8080/api/timetable/availability', { + const res = await axios.get('https://star-isih.onrender.com/api/timetable/availability', { params: { building, room, week: formatDate(startOfWeek) } }); applyGridFromAvailability(res.data.availability); @@ -149,7 +149,7 @@ const RoomDetailPage = () => { try { await axios.post( - 'http://localhost:8080/api/reservations', + 'https://star-isih.onrender.com/api/reservations', { building, room, diff --git a/front/src/pages/SignupPage.js b/front/src/pages/SignupPage.js index 2edef66..e22cf1d 100644 --- a/front/src/pages/SignupPage.js +++ b/front/src/pages/SignupPage.js @@ -35,7 +35,7 @@ const SignupPage = () => { const handleSignup = async () => { try { - await axios.post('http://localhost:8080/api/users/register', form); + await axios.post('https://star-isih.onrender.com/api/users/register', form); alert('회원가입 성공!'); window.location.href = '/login'; } catch (err) {