hrms-user/src/plugins/axios.ts

25 lines
555 B
TypeScript
Raw Normal View History

2024-08-28 11:14:21 +07:00
import axios from "axios";
import { getToken } from "./auth";
2023-08-08 14:03:12 +07:00
// import { dotnetPath } from "../path/axiosPath";
// import { getToken } from "@baloise/vue-keycloak";
const axiosInstance = axios.create({
2024-08-28 11:14:21 +07:00
withCredentials: false,
});
2023-08-08 14:03:12 +07:00
// axiosInstance.defaults.baseURL = dotnetPath;
axiosInstance.interceptors.request.use(
2024-08-28 11:14:21 +07:00
async (config) => {
const token = await getToken();
config.headers = {
Authorization: `Bearer ${token}`,
};
return config;
},
(error) => {
Promise.reject(error);
}
);
2023-08-08 14:03:12 +07:00
2024-08-28 11:14:21 +07:00
export default axiosInstance;