2024-04-15 11:54:12 -07:00
|
|
|
import { apiBaseUrl, artifactApiBaseUrl, envCredential } from "@/util/env";
|
2024-04-01 21:34:52 +03:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
|
|
const client = axios.create({
|
|
|
|
|
baseURL: apiBaseUrl,
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
2024-04-15 11:54:12 -07:00
|
|
|
"x-api-key": envCredential,
|
2024-04-01 21:34:52 +03:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-07 21:52:59 +03:00
|
|
|
const artifactApiClient = axios.create({
|
|
|
|
|
baseURL: artifactApiBaseUrl,
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-15 11:54:12 -07:00
|
|
|
export function setAuthorizationHeader(token: string) {
|
|
|
|
|
client.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function removeAuthorizationHeader() {
|
|
|
|
|
delete client.defaults.headers.common["Authorization"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setApiKeyHeader(apiKey: string) {
|
|
|
|
|
client.defaults.headers.common["X-API-Key"] = apiKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function removeApiKeyHeader() {
|
|
|
|
|
delete client.defaults.headers.common["X-API-Key"];
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 21:52:59 +03:00
|
|
|
export { client, artifactApiClient };
|