Skip to content

Commit 0b0a020

Browse files
committed
fix(ui): migrate ssh service from deprecated apiBase to apiConfig
1 parent b2973db commit 0b0a020

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/ui/services/ssh.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios, { AxiosResponse } from 'axios';
22
import { getAxiosConfig } from './auth';
3-
import { API_BASE } from '../apiBase';
3+
import { getBaseUrl } from './apiConfig';
44

55
export interface SSHKey {
66
fingerprint: string;
@@ -15,16 +15,18 @@ export interface SSHConfig {
1515
}
1616

1717
export 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

2526
export 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

4649
export 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

Comments
 (0)