This article will take you through how to use Requestly to simulate fake 404 and 500 response status codes and test your frontend app without changing anything in your codebase. There are two possible ways to solve this using Requestly:
- Requestly Desktop App (1 step)
- Requestly Chrome Extension (2 step)
Using Desktop App
Any MITM proxy can intercept the request and simulate the status code. However, using Requestly Desktop app, it is possible in a single step.
- Go to Rules Tab and click New Rule.
- Select Modify Response.
- Define the exact URL (or Pattern) and define the status code and Save the rule

Here's a step by step video demo explaining the same.
Download Requestly Desktop App from here.
Using Browser Extension
Requestly Browser Extension can simulate different status codes on an API by redirecting the actual API to a mock API using Requestly's Redirect Rule.

Create a mock API using Requestly
Requestly has a Mock Server capability to create a Mock API response. Here are the steps to create one.
- Create a new mock API here: Create Mock Server
- Set the status code you want to simulate (404, 500 …).

Example mock simulating 500 status code- https://app.requestly.io/mock/aIfQd7toGFUMCL0PZDrc
Redirecting the actual API endpoint to the Mock Server endpoint.
Set up a redirect rule to redirect the actual API to the requestly mock API.

Redirecting Blinkit Search API to a mock API simulating 404 status code
Removing Content-Security-Policy Headers
Sometimes redirection to mock API won’t work due to the Content-Security-Policy- connect-src directive, which restricts the URLs loaded using script interfaces.
You can bypass content-security-policy header using Requestly's built-in template.

Download the Requestly browser extension from here.
I hope this empowers you to do robust testing of your frontend app/website by simulating different API behaviours.
Further Resources:
Happy Debugging!