Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Request Modification — Redirect URL (Map Local, Map Remote)
Request Modification — Replace Strings (Switch Hosts, API Endpoints)
Request Modification — Modify Headers
Request Modification — Modify Request Body
Response Modification — Modify Response Body
Request Modification — Modify Query Params
Request Modification — Modify User Agents
Request Modification — Delay Request
Request Modification — Map Local
Request Modification — Map Remote
Response Modification — Modify DOM/Inject scripts
Response Modification — Cancel Rule
Predefined Functions
Organizing Rule — Grouping
Organizing Rule — Import/Export Rules from File
Organizing Rule — Pause/Resume Requestly
Organizing Rule — Rule Operators
Organizing Rule — Advance Targeting
Organizing Rule — Sharing Rules
Organizing Rule — Pinning Rules
GraphQL - Modify Request & Response
Import / Export — Charles Proxy Rules
Test Rules — Test URL Condition
Test Rules — Test this Rule
Session Book
Session Book
File Server
File Server
Public API
Public API
FAQ
FAQ
Guides
Guides
TroubleShooting
TroubleShooting
Subscription & Billing
Subscription & Billing
Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Request Modification — Redirect URL (Map Local, Map Remote)
Request Modification — Replace Strings (Switch Hosts, API Endpoints)
Request Modification — Modify Headers
Request Modification — Modify Request Body
Response Modification — Modify Response Body
Request Modification — Modify Query Params
Response Modification — Modify DOM/Inject scripts
Request Modification — Modify User Agents
Request Modification — Delay Request
Response Modification — Cancel Rule
Organizing Rule — Grouping
Organizing Rule — Import/Export Rules from File
Organizing Rule — Pause/Resume Requestly
Organizing Rule — Rule Operators
Organizing Rule — Advance Targeting
Organizing Rule — Sharing Rules
Request Modification — Map Local
Request Modification — Map Remote
Organizing Rule — Pinning Rules
GraphQL - Modify Request & Response
Import / Export — Charles Proxy Rules
Test Rules — Test URL Condition
Predefined Functions
Test Rules — Test this Rule
File Server
File Server
Public API
Public API
Sessions Replay
Sessions Replay
Guides
Guides
Session Book
Session Book
Subscription & Billing
Subscription & Billing
Modifying response asynchronously
Before going into Async Modifications, lets learn about Requestly Response Rule a little bit.
Requestly Response Rule comes in handy when you have to modify the response of a Request. You can either modify the response using
Static Data
or Programmatically
write a script to modify the response.Programmatic Response Rule
Modifying Response body using Programmatic mode is really powerful. You can modify the response body programmatically based on incoming request's headers, status code, request method etc.
For example, this rule changes the response body to
{"foo": "bar"}
when request method is GET
and return original response for rest of the methods.function modifyResponse(args) { const {method, url, response, responseType, requestHeaders, requestData, responseJSON} = args; // Change response below depending upon request attributes received in args if(method === "GET") { return {"foo": "bar"} } return response; }
Async Modifications
Async modifications lets you perform some long running tasks before returning the response. You can learn about async await from here. This can be helpful in the following scenarios:
In Extension, async/await will work only for requests made usingfetch
Usecases
- Adding delays in Response (This is also possible using Requestly Delay Rule)
Example 1
In this example, we'll try to hit an external URL to fetch the auth_token and then add the token in the original response.
- Fetching Token from URL
https://demo_requestly.requestly.dev/auth_token
.
- Adding token in Response.
Example 2
This example changes the response of a non-existent domain (https://non-existent-url.com) by fetching the response from another url (https://demo_requestly.requestly.dev/users/1)