This commit is contained in:
focp212@naver.com
2025-10-29 15:51:51 +09:00
parent b0caff51e8
commit 777521a960
11 changed files with 106 additions and 16 deletions

View File

@@ -4,17 +4,20 @@ import { WHITE_LIST_URLS } from '@/shared/api/urls';
import { StorageKeys } from '@/shared/constants/local-storage';
import { checkIsAxiosError, getLocalStorage, setLocalStorage } from '@/shared/lib';
import { finalizeConfig } from './utils';
import { HEADER_USER_AGENT } from '@/shared/constants/url';
import { appBridge } from '@/utils/appBridge';
import { useAppBridge } from '@/hooks';
import { useUserInfo } from '@/entities/user/lib/use-user-info';
import { LoginResponse } from '@/entities/user/model/types';
import { useStore } from '@/shared/model/store';
import { getHeaderUserAgent } from '@/shared/constants/url';
const onRequestFulfilled = (config: InternalAxiosRequestConfig) => {
config.headers['Content-Type'] = 'application/json;charset=UTF-8';
config.headers['X-User-Agent'] = HEADER_USER_AGENT;
if(!config.headers['X-User-Agent']){
config.headers['X-User-Agent'] = getHeaderUserAgent();
}
if(WHITE_LIST_URLS.includes(config?.url ?? '')){
if(config.headers.hasOwnProperty('Authorization')){
delete config.headers.Authorization;

View File

@@ -19,7 +19,7 @@ const getAPIAuthBaseUrl = () => {
}
return rs;
}
const getHeaderUserAgent = (options?: {
export const getHeaderUserAgent = (options?: {
menuId?: number,
apiType?: string
}) => {
@@ -32,12 +32,11 @@ const getHeaderUserAgent = (options?: {
let appVersion = '1.0.0';
let browserInformation = result.browser.name;
return `${os} ${deviceType} ${deviceID} ${appVersion} ${browserInformation} ${options?.menuId} ${options?.apiType}`;
return `${os} ${deviceType} ${deviceID} ${appVersion} ${browserInformation} ${options?.menuId || ''} ${options?.apiType || ''}`;
};
export const API_BASE_URL = getAPIBaseUrl();
export const API_AUTH_BASE_URL = getAPIAuthBaseUrl();
export const API_URL_KEY = 'nmsa';
export const HEADER_USER_AGENT = getHeaderUserAgent();
export const API_PARAM = {};