22import React , { useEffect , useState , useMemo , useRef } from "react" ;
33import { useParams , useNavigate } from "react-router-dom" ;
44import "./PostDetail.css" ;
5-
6- const API_BASE = "http://52.79.145.160:8080" ;
5+ import config from "../../config" ;
76
87export 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 } ) ;
0 commit comments