Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-chefs-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mappersmith': patch
---

Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici
Copy link
Copy Markdown
Collaborator

@klippx klippx Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici
Update the `performRequest` method in all gateways to normalize the HTTP method to uppercase. This is to ensure users of mappersmith can continue to use lowercase methods in their manifest and still be compatible with fetch libraries that are equipped with a case sensitive fetch mechanism.

4 changes: 2 additions & 2 deletions src/gateway/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Fetch extends Gateway {
}

const customHeaders: Record<string, string> = {}
const body = this.prepareBody(requestMethod, customHeaders)
const body = this.prepareBody(requestMethod.toUpperCase(), customHeaders)
const auth = this.request.auth()

if (auth) {
Expand All @@ -66,7 +66,7 @@ export class Fetch extends Gateway {
}

const headers = assign(customHeaders, this.request.headers())
const method = this.shouldEmulateHTTP() ? 'post' : requestMethod
const method = this.shouldEmulateHTTP() ? 'POST' : requestMethod.toUpperCase()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same should be done in two more files, I know this was originally only for Fetch gateway but the way I see it this is not about your specific case and changing Fetch to be different just because of undici:

  • src/gateway/http.ts
  • src/gateway/xhr.ts

const userSignal = this.request.signal()

// Since 1) node fetch requires timeout to be handled via abort controller and 2) we support an external user signal, we need to merge them:
Expand Down
Loading