File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ // axiosInstance.ts
2+
13import axios from "axios" ;
24
35const axiosInstance = axios . create ( {
46 baseURL : "https://sp-taskify-api.vercel.app" ,
57} ) ;
68
9+ // 👉 Authorization 헤더 자동 설정, 요청 보낼때 마다 localstorage에서 토큰 가져오기
10+ axiosInstance . interceptors . request . use ( ( config ) => {
11+ const token = localStorage . getItem ( "accessToken" ) ; // localStorage에서 토큰 가져오기
12+ if ( token ) {
13+ config . headers . Authorization = `Bearer ${ token } ` ; // 헤더에 Authorization 추가
14+ }
15+ return config ;
16+ } ) ;
17+
718// 👉 요청 보낼 때마다 토큰 자동 추가
819axiosInstance . interceptors . request . use ( ( config ) => {
920 const token = localStorage . getItem ( "accessToken" ) ; // localStorage에서 토큰 가져오기
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import ModalInput from "@/components/modalInput/ModalInput";
55import ModalTextarea from "@/components/modalInput/ModalTextarea" ;
66import ModalImage from "@/components/modalInput/ModalImage" ;
77import TextButton from "@/components/modalInput/TextButton" ;
8+ import { useRouter } from "next/router" ;
89
910interface TaskModalProps {
1011 isOpen : boolean ;
@@ -42,6 +43,8 @@ export default function TaskModal({
4243 image : "" ,
4344 } ) ;
4445
46+ const router = useRouter ( ) ;
47+
4548 const handleChange = ( field : keyof TaskData , value : string | string [ ] ) => {
4649 setFormData ( ( prev ) => ( {
4750 ...prev ,
@@ -78,6 +81,7 @@ export default function TaskModal({
7881 imageUrl : formData . image || undefined ,
7982 } ) ;
8083
84+ router . reload ( ) ; // 카드 생성 후 새로고침
8185 onClose ( ) ;
8286 } catch ( err ) {
8387 console . error ( "카드 생성 실패:" , err ) ;
You can’t perform that action at this time.
0 commit comments