mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-26 19:26:33 +00:00
26 lines
511 B
TypeScript
26 lines
511 B
TypeScript
import axios from "axios"
|
|
|
|
const API_BASE_URL = process.env.NEXT_PUBLIC_BACKEND_URL || "http://127.0.0.1:5000"
|
|
|
|
const api = axios.create({
|
|
baseURL: API_BASE_URL,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
})
|
|
|
|
api.interceptors.request.use(
|
|
(config) => {
|
|
const token = localStorage.getItem("openlearnx_jwt_token")
|
|
if (token) {
|
|
config.headers.Authorization = `Bearer ${token}`
|
|
}
|
|
return config
|
|
},
|
|
(error) => {
|
|
return Promise.reject(error)
|
|
},
|
|
)
|
|
|
|
export default api
|