diff --git a/src/App.js b/src/App.js index f75ba64..f0a576f 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,8 @@ import Navbar from './components/Navbar'; import Footer from './components/Footer'; import Home from './pages/Home'; import About from './pages/About'; -import Board from './pages/Board'; +import PostList from './pages/PostList'; +import PostCreate from './pages/PostCreate'; import PostCategory from './pages/PostCategory'; import Login from './pages/Login'; import { AuthProvider } from './context/AuthContext'; @@ -19,7 +20,8 @@ function App() { } /> } /> - } /> + } /> + } /> } /> } /> diff --git a/src/api/api.js b/src/api/api.js deleted file mode 100644 index 0566d98..0000000 --- a/src/api/api.js +++ /dev/null @@ -1,20 +0,0 @@ -// src/api/api.js -import axios from 'axios'; - -const api = axios.create({ - baseURL: process.env.REACT_APP_API_URL, // ✅ 환경변수에서 읽어옴 - headers: { - 'Content-Type': 'application/json', - } -}); - -// 요청에 JWT 자동 포함 -api.interceptors.request.use(config => { - const token = localStorage.getItem('access'); - if (token) { - config.headers.Authorization = `Bearer ${token}`; - } - return config; -}); - -export default api; diff --git a/src/api/authApi.js b/src/api/authApi.js new file mode 100644 index 0000000..e04c1b1 --- /dev/null +++ b/src/api/authApi.js @@ -0,0 +1,20 @@ +// src/api/authApi.js +import axios from 'axios'; + +const authApi = axios.create({ + baseURL: process.env.REACT_APP_API_AUTH, + headers: { + 'Content-Type': 'application/json', + } +}); + +// JWT 자동 포함 (로그인 이후 /me 호출 등에 사용 가능) +authApi.interceptors.request.use(config => { + const token = localStorage.getItem('access'); + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + return config; +}); + +export default authApi; diff --git a/src/api/blogApi.js b/src/api/blogApi.js new file mode 100644 index 0000000..c70f029 --- /dev/null +++ b/src/api/blogApi.js @@ -0,0 +1,20 @@ +// src/api/blogApi.js +import axios from 'axios'; + +const blogApi = axios.create({ + baseURL: process.env.REACT_APP_API_BLOG, + headers: { + 'Content-Type': 'application/json', + } +}); + +// 게시글 작성 시에도 JWT 필요하므로 interceptor 동일하게 구성 +blogApi.interceptors.request.use(config => { + const token = localStorage.getItem('access'); + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + return config; +}); + +export default blogApi; diff --git a/src/components/Navbar.js b/src/components/Navbar.js index c9e3285..526a710 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -4,10 +4,10 @@ import { useAuth } from '../context/AuthContext'; // ✅ Context에서 로그 const Navbar = () => { const navigate = useNavigate(); - const { isLoggedIn, logout } = useAuth(); // ✅ 로그인 상태 + 로그아웃 함수 + const { isLoggedIn, logout } = useAuth(); - const menuItems = ['home', 'about', 'board', 'etc']; - const postCategories = ['developer', 'systemengineer', 'etc']; + // ✅ 'board' → 'posts'로 변경 + const menuItems = ['home', 'about', 'posts']; return (