Skip to content

Commit a290703

Browse files
authored
Merge pull request #83 from DMU-DebugVisual/inseong
url change
2 parents 2fd47cf + 0d45897 commit a290703

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.env.development.local
1818
.env.test.local
1919
.env.production.local
20+
.vscode
2021

2122
npm-debug.log*
2223
yarn-debug.log*

src/components/community/Community.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useEffect, useState } from "react";
22
import { useNavigate } from "react-router-dom";
33
import "./Community.css";
4-
5-
const API_BASE = "http://52.79.145.160:8080";
4+
import config from "../../config";
65

76
export default function Community() {
87
const navigate = useNavigate();
@@ -33,7 +32,7 @@ export default function Community() {
3332
headers.Authorization = `Bearer ${token}`;
3433
}
3534

36-
const res = await fetch(`${API_BASE}/api/posts`, {
35+
const res = await fetch(`${config.API_BASE_URL}/api/posts`, {
3736
method: "GET",
3837
headers,
3938
signal: controller.signal,

src/components/community/CommunityWrite.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
FaImage, FaHeading, FaListUl, FaListOl, FaMinus
66
} from "react-icons/fa";
77
import "./CommunityWrite.css";
8-
9-
const API_BASE = "http://52.79.145.160:8080";
8+
import config from "../../config";
109

1110
// ✅ 백엔드 ENUM과 일치하는 허용 태그
1211
const ALLOWED_TAGS = [
@@ -102,7 +101,7 @@ export default function CommunityWrite() {
102101

103102
try {
104103
setSubmitting(true);
105-
const res = await fetch(`${API_BASE}/api/posts`, {
104+
const res = await fetch(`${config.API_BASE_URL}/api/posts`, {
106105
method: "POST",
107106
headers: {
108107
"Content-Type": "application/json",

src/components/community/PostDetail.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import React, { useEffect, useState, useMemo, useRef } from "react";
33
import { useParams, useNavigate } from "react-router-dom";
44
import "./PostDetail.css";
5-
6-
const API_BASE = "http://52.79.145.160:8080";
5+
import config from "../../config";
76

87
export default function PostDetail() {
98
const { id } = useParams(); // /community/post/:id
@@ -62,7 +61,7 @@ export default function PostDetail() {
6261
const refreshLikeCount = async () => {
6362
try {
6463
const bust = Date.now();
65-
const res = await fetch(`${API_BASE}/api/posts/${id}/like?t=${bust}`, {
64+
const res = await fetch(`${config.API_BASE_URL}/api/posts/${id}/like?t=${bust}`, {
6665
method: "GET",
6766
headers: { Accept: "*/*", "Cache-Control": "no-cache", Pragma: "no-cache" },
6867
cache: "no-store",
@@ -97,7 +96,7 @@ export default function PostDetail() {
9796
}
9897

9998
// ✅ 게시글 상세
100-
const res = await fetch(`${API_BASE}/api/posts/${id}`, {
99+
const res = await fetch(`${config.API_BASE_URL}/api/posts/${id}`, {
101100
method: "GET",
102101
headers: { Accept: "application/json", Authorization: authHeader },
103102
signal: controller.signal,
@@ -152,7 +151,7 @@ export default function PostDetail() {
152151
setLoadingComments(true);
153152

154153
// ✅ 댓글 목록 (배열/페이지객체 모두 대응)
155-
const res = await fetch(`${API_BASE}/api/comments/${id}`, {
154+
const res = await fetch(`${config.API_BASE_URL}/api/comments/${id}`, {
156155
method: "GET",
157156
headers: { Accept: "application/json", Authorization: authHeader },
158157
signal: controller.signal,
@@ -211,7 +210,7 @@ export default function PostDetail() {
211210
setLikeCount((c) => Math.max(0, c + (willLike ? 1 : -1)));
212211

213212
// 2) 서버 토글 호출
214-
const res = await fetch(`${API_BASE}/api/posts/${id}/like`, {
213+
const res = await fetch(`${config.API_BASE_URL}/api/posts/${id}/like`, {
215214
method: "POST",
216215
headers: {
217216
Accept: "application/json",
@@ -255,7 +254,7 @@ export default function PostDetail() {
255254

256255
try {
257256
setPosting(true);
258-
const res = await fetch(`${API_BASE}/api/comments`, {
257+
const res = await fetch(`${config.API_BASE_URL}/api/comments`, {
259258
method: "POST",
260259
headers: {
261260
"Content-Type": "application/json",
@@ -277,7 +276,7 @@ export default function PostDetail() {
277276

278277
// 🔄 작성 후 최신 목록/개수 재조회
279278
const bust = Date.now();
280-
const refresh = await fetch(`${API_BASE}/api/comments/${id}?t=${bust}`, {
279+
const refresh = await fetch(`${config.API_BASE_URL}/api/comments/${id}?t=${bust}`, {
281280
headers: { Accept: "application/json", Authorization: authHeader, "Cache-Control": "no-cache", Pragma: "no-cache" },
282281
cache: "no-store",
283282
});

src/components/header/Header.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NavLink, Link, useNavigate, useLocation } from "react-router-dom";
33
import { FaMoon, FaSun, FaUserCircle, FaBell } from "react-icons/fa";
44
import "./Header.css";
55
import logoImage from '../../assets/logo3.png';
6+
import config from '../../config';
67

78
const Header = ({ isDark, setIsDark, isLoggedIn, nickname, onLoginModalOpen }) => {
89
const [isUserMenuOpen, setIsUserMenuOpen] = useState(false);
@@ -23,7 +24,7 @@ const Header = ({ isDark, setIsDark, isLoggedIn, nickname, onLoginModalOpen }) =
2324
const token = localStorage.getItem('token');
2425
if (!token) return;
2526

26-
const response = await fetch('http://52.79.145.160:8080/api/notifications', {
27+
const response = await fetch(`${config.API_BASE_URL}/api/notifications`, {
2728
method: 'GET',
2829
headers: {
2930
'Content-Type': 'application/json',
@@ -78,7 +79,7 @@ const Header = ({ isDark, setIsDark, isLoggedIn, nickname, onLoginModalOpen }) =
7879
const handleNotificationRead = async (id) => {
7980
try {
8081
const token = localStorage.getItem('token');
81-
await fetch(`http://52.79.145.160:8080/api/notifications/${id}/read`, {
82+
await fetch(`${config.API_BASE_URL}/api/notifications/${id}/read`, {
8283
method: 'PUT',
8384
headers: {
8485
'Authorization': `Bearer ${token}`

0 commit comments

Comments
 (0)