PAMapp/pages/questionnaire/_agentNo.vue | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
PAMapp/shared/services/httpClient.ts | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 |
PAMapp/pages/questionnaire/_agentNo.vue
@@ -453,9 +453,7 @@ //////////////////////////////////////////////////////////////////////////// async sentDemand() { if (typeof this.isEditBtn !== 'undefined' && this.isEditBtn) { await this.editAppointmentDemand(); } else { if (!this.isEditBtn) { // 使用 async/await 來等待異步操作的回傳結果 const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }]; const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList); @@ -472,6 +470,8 @@ throw new Error('this.editAppointmentDemand is not defined or not a function.'); } } } else { await this.editAppointmentDemand(); } const editSettingInfo: UserSetting = { PAMapp/shared/services/httpClient.ts
@@ -13,25 +13,20 @@ '/api/access_analysis/insert' ]; const BASE_URL = process.env.BASE_URL!; function sanitizeBaseUrl(baseUrl: string): string { const pattern = /^(https?:\/\/).+/i; if (!pattern.test(baseUrl)) { throw new Error('Invalid BASE_URL'); function getBaseUrl(): string { const baseUrl = process.env.BASE_URL; if (!baseUrl) { throw new Error('BASE_URL is not defined in process.env'); } const cleanedBaseUrl = cleanUrl(baseUrl); return cleanedBaseUrl; // const pattern = /^(https?:\/\/)[\w.-]+(:\d+)?/i; // 更嚴格的URL驗證 // if (!pattern.test(baseUrl)) { // throw new Error('Invalid BASE_URL'); // } // 不需要再清理URL,因為它已經是絕對URL return baseUrl; } function cleanUrl(url: string): string { const cleanedUrl = url.replace(/[^a-zA-Z0-9:/._-]/g, ''); return cleanedUrl; } export const http = axios.create({ baseURL: sanitizeBaseUrl(BASE_URL), baseURL: getBaseUrl(), // 使用函數動態獲取baseURL withCredentials: true });