import axios from "axios";
import { requestLogger, responseLogger } from "axios-logger";
import store from "@/store";

const request = axios.create({
	baseURL: import.meta.env.MODE === "development" ? "/dev-api" : "/prod-api",
});

request.interceptors.request.use((config) => {
	// 是否需要设置 token
	if (config.headers.isToken !== false) {
		config.headers["Authorization"] = "Bearer " + store.getters.getToken; // 让每个请求携带自定义token 请根据实际情况自行修改
	}
	return config;
});

request.interceptors.response.use((res) => {
	return res;
});

export default request;
