diff --git a/lib/request.js b/lib/request.js index 224cedb..29e595f 100644 --- a/lib/request.js +++ b/lib/request.js @@ -266,6 +266,9 @@ module.exports.agent = TestAgent; */ function Test (app, method, path) { + method = method.toUpperCase(); // Do this in order to avoid "patch" being sent as lowercase. + // This makes the preflight request -when running in browser- to be sent as "Access-Control-Request-Method = patch" instead of "Access-Control-Request-Method = PATCH" + // Which causes problems with those kind of requests. For further reference: https://stackoverflow.com/questions/55250297/problem-with-patch-method-and-cors-preflight-request?rq=1 Request.call(this, method, path); this.app = app; this.url = typeof app === 'string' ? app + path : serverAddress(app, path);