ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.35k stars 177 forks source link

Changing URL in scripting #1955

Closed novitae closed 4 months ago

novitae commented 4 months ago

Description

When making a script, and in onRequest doing request.url = "https://mynew.url/", the URL of the request doesn't change. Is it normal ?

Steps to Reproduce

Current Behavior

Url not changed

Expected Behavior

Url changed to the new one

Environment

NghiaTranUIT commented 4 months ago

It's because request.url is read-only.

To change the URL components, please use the code:

function onRequest(context, url, request) {
    request.scheme = "http";
    request.host = "proxyman.dev";
    request.port = 9090;
    request.path = "v1/data/user";
    return request;
}

Snippet Code: https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path