Skip to content

Trouble triggering scripts from iOS simulator #1950

@ben-codes-five

Description

@ben-codes-five

Description

I am doing iOS development and monitoring network traffic using Proxyman.
I can see the network calls in Proxyman, suggesting I have the certificates set up correctly, however, I am trying to modify the response for an endpoint using scripts but the scripts aren't being triggered.

For context, the endpoint is a graphql endpoint and below is my script:

const file = require("mockdata.json");

async function onRequest(context, url, request) {
  // console.log(request);
  console.log(url);

  // 1. Extract the queryName from the request
  var queryName = request.body.query.match(/\S+/gi)[1].split('(').shift();

  // 2. Save to sharedState
  sharedState.queryName = queryName

  // Done
  return request;
}

async function onResponse(context, url, request, response) {

  // 3. Check if it's the request we need to map
  if (sharedState.queryName == "myQuery") {

    // 4. Import the local file by Action Button -> Import
    // Get the local JSON file and set it as a body (like Map Local)
    response.headers["Content-Type"] = "application/json";
    response.body = file;
  }

  // Done
  return response;
}

I can confirm the script works because I am able to trigger the script by rerunning the request within Proxyman, however, I am unable to trigger the script from sending a request from my iOS app.

Any idea what the issue is? Smells like either an internal bug or a configuration issue.

Environment

  • App version: Proxyman 5.0.0
  • macOS version: macOS Sonoma 14.3.1
  • Xcode version: Xcode 15.1
  • Simulator version: Simulator 15.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions