Replies: 1 comment
-
Hey, @BMCwebdev. Although Service Workers can capture such static assets on page load, MSW is a little different. Our worker self-destructs when its last client unloads. This includes the case when you refresh the page. What actually happens is that the worker unregisters itself when the page unloads, then your page loads your JavaScript code that calls There's a loading gap between the page load and its JavaScript being executed. That's one of the reasons why MSW cannot intercept the requests from the We are explicitly bypassing any initial load assets: Lines 261 to 266 in 9373ccf Lines 151 to 157 in 9373ccf We do so that you couldn't mock your MSW is primarily meant for interactive requests. Basically, any |
Beta Was this translation helpful? Give feedback.
-
Just getting started, and have been looking around for an answer on this one. Should MSW be able to redirect a GET for a
<link>
or<script>
tag in the<head>
? Something along the lines of:rest.get("/styles.css", (req, res, ctx) => { return res( ctx.status(307), ctx.set("Location", "/test/styles.css") ); })
I forked a demo CodeSandbox, added a link tag in the index.html' s
<head>
and tried the above code without luck. Link is below:https://codesandbox.io/s/hardcore-benz-4bw1b
Beta Was this translation helpful? Give feedback.
All reactions