Skip to content

Commit 415257c

Browse files
fix(deps): update dependency msw to ^2.6.7 (#1763)
* fix(deps): update dependency msw to ^2.6.7 * Update --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <[email protected]>
1 parent 1420110 commit 415257c

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

packages/redux-devtools-rtk-query-monitor/demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@redux-devtools/rtk-query-monitor": "workspace:^",
2121
"@reduxjs/toolkit": "^2.4.0",
2222
"framer-motion": "^11.13.1",
23-
"msw": "^2.4.7",
23+
"msw": "^2.6.7",
2424
"react": "^18.3.1",
2525
"react-dom": "^18.3.1",
2626
"react-icons": "^5.4.0",

packages/redux-devtools-rtk-query-monitor/demo/public/mockServiceWorker.js

+31-8
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.4.7'
12-
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
11+
const PACKAGE_VERSION = '2.6.7'
12+
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
1313
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1414
const activeClientIds = new Set()
1515

@@ -62,7 +62,12 @@ self.addEventListener('message', async function (event) {
6262

6363
sendToClient(client, {
6464
type: 'MOCKING_ENABLED',
65-
payload: true,
65+
payload: {
66+
client: {
67+
id: client.id,
68+
frameType: client.frameType,
69+
},
70+
},
6671
})
6772
break
6873
}
@@ -155,6 +160,10 @@ async function handleRequest(event, requestId) {
155160
async function resolveMainClient(event) {
156161
const client = await self.clients.get(event.clientId)
157162

163+
if (activeClientIds.has(event.clientId)) {
164+
return client
165+
}
166+
158167
if (client?.frameType === 'top-level') {
159168
return client
160169
}
@@ -183,12 +192,26 @@ async function getResponse(event, client, requestId) {
183192
const requestClone = request.clone()
184193

185194
function passthrough() {
186-
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+
)
187208

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

193216
return fetch(requestClone, { headers })
194217
}

pnpm-lock.yaml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)