Skip to content

Commit

Permalink
Convert verb to uppercase
Browse files Browse the repository at this point in the history
In Google Chrome, `patch` specifically seems to be causing problems. I'd been Googling for about an hour and finally came across this SO post: https://stackoverflow.com/a/67744766/51021

Apparently, some verbs (`PATCH` in my case) ARE case-sensitive when comparing against a pre-flight `OPTIONS` check.

I think in order to be the most compatible with the `axios` module, and to make `PATCH` work during cross-origin requests, these verbs should be made uppercase (See `axios` source: [axios/lib/adapters/xhr.js#L32](https://github.com/axios/axios/blob/5ad6994/lib/adapters/xhr.js#L32))
  • Loading branch information
sirlancelot committed Aug 5, 2021
1 parent f963b6f commit 4020cb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default (function create(/** @type {Options} */ defaults) {
const fetchFunc = options.fetch || fetch;

return fetchFunc(url, {
method: _method || options.method,
method: (_method || options.method).toUpperCase(),
body: data,
headers: deepMerge(options.headers, customHeaders, true),
credentials: options.withCredentials ? 'include' : 'same-origin'
Expand Down

0 comments on commit 4020cb4

Please sign in to comment.