Merge pull request '260716_04_ENH: 내부 통신용 API 통신 실패 시 alert 노출 X' (#6) from develop into master
Reviewed-on: #6
This commit is contained in:
@@ -1,8 +1,19 @@
|
|||||||
import { clientEnv } from "@/lib/env.client";
|
import { clientEnv } from "@/lib/env.client";
|
||||||
import { createHttpClient } from "@kri/common/http";
|
import { createHttpClient, HttpError } from "@kri/common/http";
|
||||||
|
|
||||||
export const nextApi = createHttpClient(clientEnv.API_BASE);
|
export const nextApi = createHttpClient(clientEnv.API_BASE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내부 전용 API. 외부 접속 등으로 통신이 실패해도
|
||||||
|
* 사용자에게 오류로 비춰지지 않도록 alert/로그아웃 리다이렉트 없이 콘솔에만 기록한다.
|
||||||
|
*/
|
||||||
|
const logInternalApiError = (error: HttpError) => {
|
||||||
|
console.error("[internalApi]", error.status, error.url, error.data);
|
||||||
|
};
|
||||||
|
|
||||||
export const internalApi = createHttpClient(clientEnv.API_INTERNAL, {
|
export const internalApi = createHttpClient(clientEnv.API_INTERNAL, {
|
||||||
defaultHeaders: {},
|
defaultHeaders: {},
|
||||||
|
onUnauthorized: logInternalApiError,
|
||||||
|
onForbidden: logInternalApiError,
|
||||||
|
onResponseError: logInternalApiError,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user