diff --git a/lib/axios.ts b/lib/axios.ts index d826052f1..a847a034c 100644 --- a/lib/axios.ts +++ b/lib/axios.ts @@ -4,4 +4,19 @@ const instance = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_BASE_URL, }); +instance.interceptors.request.use( + (config) => { + const token = localStorage.getItem("accessToken"); + + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + + return config; + }, + (error) => { + return Promise.reject(error); + } +); + export default instance;