Node app traffic not captured in Charles Proxy?

Viewed 205

Freshly installed Charles will capture my browser's requests, but not any calls from Node- I'd expect to see jsonplaceholder.com in Charles. This API call returns a succesfull response in console.

const fs = require('fs');
const fetch = require("node-fetch");
 
fetch('https://jsonplaceholder.typicode.com/todos/1').then(response => {
    return response.json();
}).then(mydata => {
    console.log(mydata)
});

I also tried a solution using 'tunnel' module posted on Medium by adding this to the top of my code, and the app ran no errors, but still nothing captured in Charles.

const tunnel = require("tunnel");

var tunnelAgent = tunnel.httpsOverHttp({
  ca: [fs.readFileSync('/Users/work/charles-ssl-proxying-certificate.pem')],
  proxy: {
    host: '127.0.0.1',
    port: 8888
  }
});
0 Answers
Related