Skip to content

Commit

Permalink
Refactor API calls to use relative paths for authentication endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdcode committed Dec 17, 2024
1 parent ec184d6 commit b15b5cd
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Sources/octockup.client/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import SHA512 from "crypto-js/sha512";
import AxiosClient from "./AxiosClient";
import { API_BASE_URL } from "../config";
import { LoginRequest, AuthResponse } from "./types";

/**
Expand All @@ -20,7 +19,7 @@ export const login = async (
passwordHash: SHA512(password).toString(),
} as LoginRequest;
const response = await AxiosClient.getInstance().post<AuthResponse>(
`${API_BASE_URL}/auth/login`,
"/auth/login",
request
);
return response.data;
Expand All @@ -37,7 +36,7 @@ export const refreshAccessToken = async (
refreshToken: string
): Promise<AuthResponse> => {
const response = await AxiosClient.getInstance().post<AuthResponse>(
`${API_BASE_URL}/auth/refresh`,
"/auth/refresh",
{ refreshToken }
);
return response.data;
Expand All @@ -49,8 +48,6 @@ export const refreshAccessToken = async (
* @returns A promise that resolves to `true` if the user is authenticated, and `false` otherwise.
*/
export const checkAuth = async (): Promise<boolean> => {
const response = await AxiosClient.getInstance().get(
`${API_BASE_URL}/auth/check`
);
const response = await AxiosClient.getInstance().get("/auth/check");
return response.status === 200;
};

0 comments on commit b15b5cd

Please sign in to comment.