From 4020cb41288cec607cab7f75b0424603a71d68d6 Mon Sep 17 00:00:00 2001 From: Matthew Pietz Date: Thu, 5 Aug 2021 13:45:30 -0700 Subject: [PATCH] Convert verb to uppercase 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)) --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c266c73..207a5fb 100644 --- a/src/index.js +++ b/src/index.js @@ -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'