csvan
csvan

Reputation: 9464

Simulating an error code in Chrome dev tools

From the dev tools, is it possible to tell Chrome to return, for example, a 404 when a specific url is requested (leaving other requests to process normally)?

Upvotes: 35

Views: 33467

Answers (2)

Liem
Liem

Reputation: 770

Blocking the request with chrome devtools is the easiest solution. But if you want to mock a specific error code, let say 401 or 404 you can use a chrome extension to do it. There are plenty of them in the store, I just tried one randomly and it allowed me to mock a specific error code https://chrome.google.com/webstore/detail/mokku-mock-api-calls-seam/llflfcikklhgamfmnjkgpdadpmdplmji?hl=en

Upvotes: 8

Kayce Basques
Kayce Basques

Reputation: 26017

You can block specific request URLs or patterns of URLs from the Network panel.

block request URL

Manage your blocked URLs from the Request Blocking tab.

Request Blocking tab

Official feature announcement: https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests

Upvotes: 44

Related Questions