diff --git a/src/client/components/modals/monitor/provider/http.tsx b/src/client/components/modals/monitor/provider/http.tsx index f92450b..f6d31ea 100644 --- a/src/client/components/modals/monitor/provider/http.tsx +++ b/src/client/components/modals/monitor/provider/http.tsx @@ -56,8 +56,34 @@ const MonitorHttp: React.FC = React.memo(() => { + + + diff --git a/src/server/model/monitor/provider/http.ts b/src/server/model/monitor/provider/http.ts index 461f5fd..e93c01b 100644 --- a/src/server/model/monitor/provider/http.ts +++ b/src/server/model/monitor/provider/http.ts @@ -10,6 +10,7 @@ export const http: MonitorProvider<{ method?: string; timeout?: number; // second contentType?: string; + headers?: string; bodyValue?: string; maxRedirects?: number; ignoreTLS?: boolean; @@ -24,6 +25,7 @@ export const http: MonitorProvider<{ method = 'get', timeout = 30, contentType, + headers, bodyValue, maxRedirects, ignoreTLS, @@ -44,6 +46,20 @@ export const http: MonitorProvider<{ // }, }; + if (headers) { + try { + const customHeaders = JSON.parse(headers); + if (typeof customHeaders === 'object') { + config.headers = { + ...config.headers, + ...customHeaders, + }; + } + } catch (err) { + logger.warn('Unabled header:', headers); + } + } + if (bodyValue) { config.data = bodyValue; } @@ -55,6 +71,8 @@ export const http: MonitorProvider<{ config.httpsAgent = new https.Agent(httpsAgentOptions); + console.log('config', config); + try { const startTime = dayjs(); const res = await axios({ ...config });