Skip to content

Commit c2ea0e3

Browse files
Upgrade dev dependencies (#2639)
* Update dev dependencies * Bot commit: format with prettier * Revert openapi-gen-ts to tilde * Update vitest to beta 4 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 48e1b15 commit c2ea0e3

File tree

3 files changed

+1002
-1086
lines changed

3 files changed

+1002
-1086
lines changed

mockServiceWorker.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - Please do NOT serve this file on production.
99
*/
1010

11-
const PACKAGE_VERSION = '2.6.2'
12-
const INTEGRITY_CHECKSUM = '07a8241b182f8a246a7cd39894799a9e'
11+
const PACKAGE_VERSION = '2.7.0'
12+
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
1313
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1414
const activeClientIds = new Set()
1515

@@ -192,12 +192,26 @@ async function getResponse(event, client, requestId) {
192192
const requestClone = request.clone()
193193

194194
function passthrough() {
195-
const headers = Object.fromEntries(requestClone.headers.entries())
195+
// Cast the request headers to a new Headers instance
196+
// so the headers can be manipulated with.
197+
const headers = new Headers(requestClone.headers)
198+
199+
// Remove the "accept" header value that marked this request as passthrough.
200+
// This prevents request alteration and also keeps it compliant with the
201+
// user-defined CORS policies.
202+
const acceptHeader = headers.get('accept')
203+
if (acceptHeader) {
204+
const values = acceptHeader.split(',').map((value) => value.trim())
205+
const filteredValues = values.filter(
206+
(value) => value !== 'msw/passthrough',
207+
)
196208

197-
// Remove internal MSW request header so the passthrough request
198-
// complies with any potential CORS preflight checks on the server.
199-
// Some servers forbid unknown request headers.
200-
delete headers['x-msw-intention']
209+
if (filteredValues.length > 0) {
210+
headers.set('accept', filteredValues.join(', '))
211+
} else {
212+
headers.delete('accept')
213+
}
214+
}
201215

202216
return fetch(requestClone, { headers })
203217
}

0 commit comments

Comments
 (0)