Add auth screens (#193)

This commit is contained in:
Kerem Yilmaz
2024-04-15 11:54:12 -07:00
committed by GitHub
parent a8b156a36d
commit 6b7b9ab414
6 changed files with 78 additions and 10 deletions

View File

@@ -1,11 +1,11 @@
import { apiBaseUrl, artifactApiBaseUrl, credential } from "@/util/env";
import { apiBaseUrl, artifactApiBaseUrl, envCredential } from "@/util/env";
import axios from "axios";
const client = axios.create({
baseURL: apiBaseUrl,
headers: {
"Content-Type": "application/json",
"x-api-key": credential,
"x-api-key": envCredential,
},
});
@@ -13,4 +13,20 @@ const artifactApiClient = axios.create({
baseURL: artifactApiBaseUrl,
});
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"];
}
export { client, artifactApiClient };

View File

@@ -75,3 +75,7 @@ export type TaskApiResponse = {
failure_reason: string | null;
errors: unknown[];
};
export type User = {
name: string;
};