diff --git a/packages/pieces/community/http/package.json b/packages/pieces/community/http/package.json index ab63c5b772..e52fb0947a 100644 --- a/packages/pieces/community/http/package.json +++ b/packages/pieces/community/http/package.json @@ -1,5 +1,5 @@ { "name": "@activepieces/piece-http", - "version": "0.5.1" + "version": "0.5.2" } diff --git a/packages/pieces/community/http/src/index.ts b/packages/pieces/community/http/src/index.ts index 3b6ccb4ad6..40115c153f 100644 --- a/packages/pieces/community/http/src/index.ts +++ b/packages/pieces/community/http/src/index.ts @@ -24,3 +24,8 @@ export const http = createPiece({ ], triggers: [], }); + + +export type HttpPieceConfig = { + deniedHeaders?: string[] +} diff --git a/packages/pieces/community/http/src/lib/actions/send-http-request-action.ts b/packages/pieces/community/http/src/lib/actions/send-http-request-action.ts index b42b6cb4e5..ff352314e7 100644 --- a/packages/pieces/community/http/src/lib/actions/send-http-request-action.ts +++ b/packages/pieces/community/http/src/lib/actions/send-http-request-action.ts @@ -15,6 +15,7 @@ import FormData from 'form-data'; import { httpMethodDropdown } from '../common/props'; import { HttpsProxyAgent } from 'https-proxy-agent'; import axios from 'axios'; +import { HttpPieceConfig } from '../../index'; export const httpSendRequestAction = createAction({ name: 'send_request', @@ -163,6 +164,18 @@ export const httpSendRequestAction = createAction({ assertNotNullOrUndefined(method, 'Method'); assertNotNullOrUndefined(url, 'URL'); + const pieceConfig = context.pieceConfig as HttpPieceConfig; + const deniedHeaders = + pieceConfig.deniedHeaders?.map((header) => header.toLowerCase().trim()) || + []; + const blockedHeaders = Object.keys(headers).filter( + (headerName) => deniedHeaders.includes(headerName.toLowerCase().trim()) + ); + + if (blockedHeaders.length > 0) { + throw new Error(`These headers are not allowed: ${blockedHeaders}`); + } + const request: HttpRequest = { method, url, @@ -198,7 +211,7 @@ export const httpSendRequestAction = createAction({ proxyUrl = `http://${proxySettings.proxy_host}:${proxySettings.proxy_port}`; } - const httpsAgent = new HttpsProxyAgent(proxyUrl) + const httpsAgent = new HttpsProxyAgent(proxyUrl); const axiosClient = axios.create({ httpsAgent, });