Skip to content

Commit 8448e5b

Browse files
fix(ui): cloudfront removing X-HTTP-Method-Override header (#12571)
1 parent d6f6b05 commit 8448e5b

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

docs/rest-api/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ Payload supports a method override feature that allows you to send GET requests
738738

739739
### How to Use
740740

741-
To use this feature, include the `X-HTTP-Method-Override` header set to `GET` in your POST request. The parameters should be sent in the body of the request with the `Content-Type` set to `application/x-www-form-urlencoded`.
741+
To use this feature, include the `X-Payload-HTTP-Method-Override` header set to `GET` in your POST request. The parameters should be sent in the body of the request with the `Content-Type` set to `application/x-www-form-urlencoded`.
742742

743743
### Example
744744

@@ -753,7 +753,7 @@ const res = await fetch(`${api}/${collectionSlug}`, {
753753
headers: {
754754
'Accept-Language': i18n.language,
755755
'Content-Type': 'application/x-www-form-urlencoded',
756-
'X-HTTP-Method-Override': 'GET',
756+
'X-Payload-HTTP-Method-Override': 'GET',
757757
},
758758
body: qs.stringify({
759759
depth: 1,

packages/payload/src/utilities/handleEndpoints.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export const handleEndpoints = async ({
8181
// packages/ui/src/fields/Relationship/index.tsx
8282
if (
8383
request.method.toLowerCase() === 'post' &&
84-
request.headers.get('X-HTTP-Method-Override') === 'GET'
84+
(request.headers.get('X-Payload-HTTP-Method-Override') === 'GET' ||
85+
request.headers.get('X-HTTP-Method-Override') === 'GET')
8586
) {
8687
const search = await request.text()
8788

packages/ui/src/elements/PublishButton/ScheduleDrawer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug, defaultType, schedulePub
138138
headers: {
139139
'Accept-Language': i18n.language,
140140
'Content-Type': 'application/x-www-form-urlencoded',
141-
'X-HTTP-Method-Override': 'GET',
141+
'X-Payload-HTTP-Method-Override': 'GET',
142142
},
143143
})
144144
.then((res) => res.json())

packages/ui/src/fields/Relationship/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export const RelationshipInput: React.FC<RelationshipInputProps> = (props) => {
282282
headers: {
283283
'Accept-Language': i18n.language,
284284
'Content-Type': 'application/x-www-form-urlencoded',
285-
'X-HTTP-Method-Override': 'GET',
285+
'X-Payload-HTTP-Method-Override': 'GET',
286286
},
287287
method: 'POST',
288288
})
@@ -429,7 +429,7 @@ export const RelationshipInput: React.FC<RelationshipInputProps> = (props) => {
429429
headers: {
430430
'Accept-Language': i18n.language,
431431
'Content-Type': 'application/x-www-form-urlencoded',
432-
'X-HTTP-Method-Override': 'GET',
432+
'X-Payload-HTTP-Method-Override': 'GET',
433433
},
434434
method: 'POST',
435435
})

packages/ui/src/fields/Upload/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export function UploadInput(props: UploadInputProps) {
218218
headers: {
219219
'Accept-Language': i18n.language,
220220
'Content-Type': 'application/x-www-form-urlencoded',
221-
'X-HTTP-Method-Override': 'GET',
221+
'X-Payload-HTTP-Method-Override': 'GET',
222222
},
223223
method: 'POST',
224224
})

0 commit comments

Comments
 (0)