Files
KartHall/front/src/lib/clients/api.js
2026-01-30 20:09:37 +04:00

16 lines
613 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import axios from "axios";
import {tokenUtil} from "./TokenUtil";
const host = "localhost:8080"; //дебаг вместе с беком
// const host = "192.168.1.100:8091"; //дебаг фронта
// const host = "bar.kayashov.keenetic.pro"; //прод
export const api = () => {
const result = axios;
result.defaults.baseURL = `${window.location.protocol}//${host}/`;
if (tokenUtil.checkToken(tokenUtil.getToken())) {
result.defaults.headers.common["Authorization"] = "Bearer " + tokenUtil.getToken();
} else {
delete result.defaults.headers.common
}
return result;
}