Skip to content

Commit 10d891d

Browse files
authored
PLU-370: [CUSTOM-API-FIX-2] do not overwrite Content-Type (#823)
### TL;DR Updated Custom API header handling to ensure: * `Content-Type = application/json`, if not set by user * `Content-Type` set in Connection step is not overwritten by `Content-Type` set in Custom Headers ### What changed? - `Content-Type` header is now set for all requests to `application/json` instead of Axios' default `application/x-www-form-urlencoded` ### How to test? 1. Make a request to the custom API endpoint with no `Content-Type` set 2. Verify that the `Content-Type` header is present and is `application/json` 3. Create a Connection in **Add connection** step with a custom `Content-Type` 4. Verify that the `Content-Type` header is present and matches what was set 5. Add a different `Content-Type` to **Custom header** step 6. Verify that it does not overwrite the `Content-Type` set in the **Add connection** step ### Why make this change? The Content-Type header should be set consistently for all requests. The previous implementation only set it for requests with headers specified in the Connection step.
1 parent d3b6611 commit 10d891d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/backend/src/apps/custom-api/common/add-headers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { TBeforeRequest } from '@plumber/types'
22

33
const addHeaders: TBeforeRequest = async ($, requestConfig) => {
44
const authData = $.auth.data
5+
requestConfig.headers.set('Content-Type', 'application/json', false)
6+
57
if (authData?.headers) {
6-
requestConfig.headers.set('Content-Type', 'application/json', true)
78
Object.entries(authData.headers).forEach(([key, value]) =>
89
requestConfig.headers.set(key, value),
910
)

0 commit comments

Comments
 (0)