330ce657e23bb5cb54a21ecf4a5e82d135446348
[arvados-workbench2.git] / src / common / api / server-api.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import Axios, { AxiosInstance } from "axios";
6
7 export const API_HOST = process.env.REACT_APP_ARVADOS_API_HOST;
8
9 export const serverApi: AxiosInstance = Axios.create({
10     baseURL: API_HOST + '/arvados/v1'
11 });
12
13 export function setServerApiAuthorizationHeader(token: string) {
14     serverApi.defaults.headers.common = {
15         'Authorization': `OAuth2 ${token}`
16     };}
17
18 export function removeServerApiAuthorizationHeader() {
19     delete serverApi.defaults.headers.common.Authorization;
20 }