Is there any way to configure msw to only intercept requests to paths with certain pattern?
For example only paths start with "/api".
Currently it shows warning every time I navigate to some page of my React app.
This should do it:
worker.start({
onUnhandledRequest(req, print) {
if (req.url.pathname.startsWith('/api/') {
print.warning()
}
return;
}
})
If you want to turn it off completely use:
worker.start({
onUnhandledRequest: 'bypass',
})