11import axios , { AxiosResponse } from 'axios' ;
22import { getAxiosConfig } from './auth' ;
3- import { API_BASE } from '../apiBase ' ;
3+ import { getBaseUrl } from './apiConfig ' ;
44
55export interface SSHKey {
66 fingerprint : string ;
@@ -15,16 +15,18 @@ export interface SSHConfig {
1515}
1616
1717export const getSSHConfig = async ( ) : Promise < SSHConfig > => {
18+ const baseUrl = await getBaseUrl ( ) ;
1819 const response : AxiosResponse < SSHConfig > = await axios (
19- `${ API_BASE } /api/v1/config/ssh` ,
20+ `${ baseUrl } /api/v1/config/ssh` ,
2021 getAxiosConfig ( ) ,
2122 ) ;
2223 return response . data ;
2324} ;
2425
2526export const getSSHKeys = async ( username : string ) : Promise < SSHKey [ ] > => {
27+ const baseUrl = await getBaseUrl ( ) ;
2628 const response : AxiosResponse < SSHKey [ ] > = await axios (
27- `${ API_BASE } /api/v1/user/${ username } /ssh-key-fingerprints` ,
29+ `${ baseUrl } /api/v1/user/${ username } /ssh-key-fingerprints` ,
2830 getAxiosConfig ( ) ,
2931 ) ;
3032 return response . data ;
@@ -35,17 +37,19 @@ export const addSSHKey = async (
3537 publicKey : string ,
3638 name : string ,
3739) : Promise < { message : string ; fingerprint : string } > => {
40+ const baseUrl = await getBaseUrl ( ) ;
3841 const response : AxiosResponse < { message : string ; fingerprint : string } > = await axios . post (
39- `${ API_BASE } /api/v1/user/${ username } /ssh-keys` ,
42+ `${ baseUrl } /api/v1/user/${ username } /ssh-keys` ,
4043 { publicKey, name } ,
4144 getAxiosConfig ( ) ,
4245 ) ;
4346 return response . data ;
4447} ;
4548
4649export const deleteSSHKey = async ( username : string , fingerprint : string ) : Promise < void > => {
50+ const baseUrl = await getBaseUrl ( ) ;
4751 await axios . delete (
48- `${ API_BASE } /api/v1/user/${ username } /ssh-keys/${ encodeURIComponent ( fingerprint ) } ` ,
52+ `${ baseUrl } /api/v1/user/${ username } /ssh-keys/${ encodeURIComponent ( fingerprint ) } ` ,
4953 getAxiosConfig ( ) ,
5054 ) ;
5155} ;
0 commit comments