blob: 317dada28e2dbfab3091f4625038140c6e29db0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
const headersCommon = {
'Content-Type': 'application/json'
};
export function genCommonHeaders({ secret }) {
const h = { ...headersCommon };
if (secret) {
h['Authorization'] = `Bearer ${secret}`;
}
return h;
}
export function getAPIBaseURL({ hostname, port }) {
return `http://${hostname}:${port}`;
}
export function getURLAndInit({ hostname, port, secret }) {
const baseURL = getAPIBaseURL({ hostname, port });
const headers = genCommonHeaders({ secret });
return {
url: baseURL,
init: { headers }
};
}
|