fix(ui): cloudfront removing X-HTTP-Method-Override header (#12571)

This commit is contained in:
Jarrod Flesch
2025-05-27 15:48:51 -04:00
committed by GitHub
parent d6f6b05d77
commit 8448e5b6b6
5 changed files with 8 additions and 7 deletions

View File

@@ -738,7 +738,7 @@ Payload supports a method override feature that allows you to send GET requests
### How to Use ### How to Use
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`. 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`.
### Example ### Example
@@ -753,7 +753,7 @@ const res = await fetch(`${api}/${collectionSlug}`, {
headers: { headers: {
'Accept-Language': i18n.language, 'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET', 'X-Payload-HTTP-Method-Override': 'GET',
}, },
body: qs.stringify({ body: qs.stringify({
depth: 1, depth: 1,

View File

@@ -81,7 +81,8 @@ export const handleEndpoints = async ({
// packages/ui/src/fields/Relationship/index.tsx // packages/ui/src/fields/Relationship/index.tsx
if ( if (
request.method.toLowerCase() === 'post' && request.method.toLowerCase() === 'post' &&
request.headers.get('X-HTTP-Method-Override') === 'GET' (request.headers.get('X-Payload-HTTP-Method-Override') === 'GET' ||
request.headers.get('X-HTTP-Method-Override') === 'GET')
) { ) {
const search = await request.text() const search = await request.text()

View File

@@ -138,7 +138,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug, defaultType, schedulePub
headers: { headers: {
'Accept-Language': i18n.language, 'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET', 'X-Payload-HTTP-Method-Override': 'GET',
}, },
}) })
.then((res) => res.json()) .then((res) => res.json())

View File

@@ -282,7 +282,7 @@ export const RelationshipInput: React.FC<RelationshipInputProps> = (props) => {
headers: { headers: {
'Accept-Language': i18n.language, 'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET', 'X-Payload-HTTP-Method-Override': 'GET',
}, },
method: 'POST', method: 'POST',
}) })
@@ -429,7 +429,7 @@ export const RelationshipInput: React.FC<RelationshipInputProps> = (props) => {
headers: { headers: {
'Accept-Language': i18n.language, 'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET', 'X-Payload-HTTP-Method-Override': 'GET',
}, },
method: 'POST', method: 'POST',
}) })

View File

@@ -218,7 +218,7 @@ export function UploadInput(props: UploadInputProps) {
headers: { headers: {
'Accept-Language': i18n.language, 'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET', 'X-Payload-HTTP-Method-Override': 'GET',
}, },
method: 'POST', method: 'POST',
}) })