| | |
| | | '/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'); |
| | | } |
| | | const cleanedBaseUrl = cleanUrl(baseUrl); |
| | | return cleanedBaseUrl; |
| | | } |
| | | |
| | | function cleanUrl(url: string): string { |
| | | const cleanedUrl = url.replace(/[^a-zA-Z0-9:/._-]/g, ''); |
| | | return cleanedUrl; |
| | | } |
| | | |
| | | |
| | | export const http = axios.create({ |
| | | baseURL: process.env.BASE_URL, |
| | | withCredentials: true, |
| | | baseURL: sanitizeBaseUrl(BASE_URL), |
| | | withCredentials: true |
| | | }); |
| | | |
| | | let apiNumber = 0; |