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

@@ -45,7 +45,7 @@ export interface OAuthConnection {
* Get list of enabled OAuth providers
*/
export const getOAuthProviders = async (): Promise<OAuthProvider[]> => {
const response = await apiClient.get<{ providers: OAuthProvider[] }>('/api/auth/oauth/providers/');
const response = await apiClient.get<{ providers: OAuthProvider[] }>('/auth/oauth/providers/');
return response.data.providers;
};
@@ -54,7 +54,7 @@ export const getOAuthProviders = async (): Promise<OAuthProvider[]> => {
*/
export const initiateOAuth = async (provider: string): Promise<OAuthAuthorizationResponse> => {
const response = await apiClient.get<OAuthAuthorizationResponse>(
`/api/auth/oauth/${provider}/authorize/`
`/auth/oauth/${provider}/authorize/`
);
return response.data;
};
@@ -68,7 +68,7 @@ export const handleOAuthCallback = async (
state: string
): Promise<OAuthTokenResponse> => {
const response = await apiClient.post<OAuthTokenResponse>(
`/api/auth/oauth/${provider}/callback/`,
`/auth/oauth/${provider}/callback/`,
{
code,
state,
@@ -81,7 +81,7 @@ export const handleOAuthCallback = async (
* Get user's connected OAuth accounts
*/
export const getOAuthConnections = async (): Promise<OAuthConnection[]> => {
const response = await apiClient.get<{ connections: OAuthConnection[] }>('/api/auth/oauth/connections/');
const response = await apiClient.get<{ connections: OAuthConnection[] }>('/auth/oauth/connections/');
return response.data.connections;
};
@@ -89,5 +89,5 @@ export const getOAuthConnections = async (): Promise<OAuthConnection[]> => {
* Disconnect an OAuth account
*/
export const disconnectOAuth = async (provider: string): Promise<void> => {
await apiClient.delete(`/api/auth/oauth/connections/${provider}/`);
await apiClient.delete(`/auth/oauth/connections/${provider}/`);
};