Open 7nights opened 3 months ago
@7nights You are right, This is currently how it is designed to work.
But, if you only intend to change the response body, you can achieve the same result by using creating a programmatic modify response rule instead of a replace/redirect rule.
In there, you can make a request to the URL (the function can be made async) where you intended the request to redirect to and serve its response. I meant something like this:
async function modifyResponse(args) {
const {method, url, response, responseType, requestHeaders, requestData, responseJSON} = args;
const newResponse = await fetch(<redirection-target-url>)
return newResponse;
}
let me know if this solves your issue.
Summary
I've tried these 2 ways to try to implement something like Charles map remote which allows you to intercept requests and replace the response with another request. But I found Requestly implement these 2 features by generating a 307 http code and redirect to the new URL which doesn't work in most of my scenarios. Is this how it is designed or am I misunderstanding it?