Modifying Non-existent Domain Response
Problem
Sometimes the backend APIs which you are trying to test with frontend aren't ready yet. So you'll see DNS_PROBE_FINISHED_NXDOMAIN
error when you try to hit these endpoints from frontend. This happens because you're trying to access a “non-existent domain” which DNS probe could not find the matching IP for.

One way you can solve this is by using by using Mock Server. But this solution faces some drawbacks:
- Changing the backend url in your codebase.
- CORS errors
Solution: Requestly Way
Requestly lets you modify the response of the Non Existent Urls
without changing anything in your codebase. Here are the steps:
- Install Requestly Browser Extension or Desktop App.
- Start creating a Modify Response Rule here.
- Enter the non-existent url in the Source Field. Eg. https://non-existent-url.com
- Enter Response Status that you want to return (By default it returns 404 if you leave it empty).
- Enter Response Body that needs to be returned. You can either enter
Static Body
or return bodyProgrammatically
.
That's it. Now you can keep on working on your frontend until your backend APIs are ready :D
If you want to add some
Response Headers
too, you can do that by creatingHeaders Rule
in Requestly.
Examples
Static Body Rule
Rules: https://app.requestly.io/rules#sharedList/1677681178655-Static-Non-existent-domain-modification

These rules update the Response body of a non-existent domain (https://non-existent-url.com) to {"foo": "bar"}
using Static Response Modifications. It also add response headers to it using Headers Rule
;
Programmatic Rule:

These rules update the Response body of a non-existent domain (https://non-existent-url.com) to response of https://example.com using Programmatic Response Modifications. It also add response headers to it using Headers Rule
;