保誠-保戶業務員媒合平台
jack
2023-09-05 3ecee0fa557b7bb9e83b67e289b316f04efa9ce5
PAMapp/shared/services/httpClient.ts
@@ -10,10 +10,22 @@
  '/eService/authenticate',
  '/login/validate/get_img_code',
  '/login/validate/verify_img_code',
  '/api/access_analysis/insert'
];
const BASE_URL = process.env.BASE_URL!;
function sanitizeBaseUrl(baseUrl: string): string {
  const isValidBaseUrl = (url: string) => url.includes('api');
  if (isValidBaseUrl(baseUrl)) {
    return baseUrl;
  } else {
    throw new Error('Invalid BASE_URL');
  }
}
export const http = axios.create({
  baseURL: process.env.BASE_URL,
  baseURL: sanitizeBaseUrl(BASE_URL),
  withCredentials: true
});
@@ -48,7 +60,8 @@
function addHttpHeader(config: AxiosRequestConfig): void {
  config.headers = {
    Authorization: 'Bearer ' + localStorage.getItem('id_token')
    Authorization: 'Bearer ' + localStorage.getItem('id_token'),
    'content-type': 'application/json'
  }
}
@@ -67,7 +80,7 @@
function showErrorMessageBox(error: any): void {
  setTimeout(() => {
    // NOTE: 此為 HOT FIX 顧問登入失敗後,會出現逾時的 dialog [Tomas, 2022/7/20 14:21]
    if(error.config.url.includes('api/eService/authenticate')) return;
    if(error.config.url.includes('/eService/authenticate')) return;
    if (error.config.url.includes('/otp/sendOtp')) {
      messageBoxService.showErrorMessage('', error);
      return