refactor(api): Remove '/api' prefix from frontend API calls and config

- Removed '/api/' prefix from endpoint paths in auth.ts, notifications.ts, oauth.ts, and platform.ts to align with the backend URL reconfiguration.
- Updated 'API_BASE_URL' in config.ts to remove the '/api' suffix, ensuring that API requests are correctly routed to the root of the 'api' subdomain (e.g., http://api.lvh.me:8000/).
- Included improvements to login redirect logic in client.ts.
This commit is contained in:
poduck
2025-12-01 01:48:22 -05:00
parent 2ec78a5237
commit 92724d03b6
5 changed files with 34 additions and 30 deletions

View File

@@ -64,7 +64,7 @@ export interface User {
* Login user
*/
export const login = async (credentials: LoginCredentials): Promise<LoginResponse> => {
const response = await apiClient.post<LoginResponse>('/api/auth/login/', credentials);
const response = await apiClient.post<LoginResponse>('/auth/login/', credentials);
return response.data;
};
@@ -72,14 +72,14 @@ export const login = async (credentials: LoginCredentials): Promise<LoginRespons
* Logout user
*/
export const logout = async (): Promise<void> => {
await apiClient.post('/api/auth/logout/');
await apiClient.post('/auth/logout/');
};
/**
* Get current user
*/
export const getCurrentUser = async (): Promise<User> => {
const response = await apiClient.get<User>('/api/auth/me/');
const response = await apiClient.get<User>('/auth/me/');
return response.data;
};
@@ -87,7 +87,7 @@ export const getCurrentUser = async (): Promise<User> => {
* Refresh access token
*/
export const refreshToken = async (refresh: string): Promise<{ access: string }> => {
const response = await apiClient.post('/api/auth/refresh/', { refresh });
const response = await apiClient.post('/auth/refresh/', { refresh });
return response.data;
};
@@ -99,7 +99,7 @@ export const masquerade = async (
hijack_history?: MasqueradeStackEntry[]
): Promise<LoginResponse> => {
const response = await apiClient.post<LoginResponse>(
'/api/auth/hijack/acquire/',
'/auth/hijack/acquire/',
{ user_pk, hijack_history }
);
return response.data;
@@ -112,7 +112,7 @@ export const stopMasquerade = async (
masquerade_stack: MasqueradeStackEntry[]
): Promise<LoginResponse> => {
const response = await apiClient.post<LoginResponse>(
'/api/auth/hijack/release/',
'/auth/hijack/release/',
{ masquerade_stack }
);
return response.data;