got-tls icon indicating copy to clipboard operation
got-tls copied to clipboard

tough-cookie not working

Open fpena06 opened this issue 3 years ago • 2 comments

When trying to use it with tough-cookie I get the following error. UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'secure' of undefined

  'use strict'
  const { Server, got } = require('got-tls');
  const tough = require('tough-cookie');

  async function run() {
      Server.connect();
      let cookie = new tough.CookieJar();
      let response = await got.get('http://ja3er.com/', {
          headers: {
              'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0'
          },
          debug: true,
          redirect: false,
          cookieJar: cookie,
      });
  }

  run();

fpena06 avatar Oct 16 '21 20:10 fpena06

you are getting this issue when the request is ran ? ive seen this issue when trying to get the cookies from the jar but its usually cause from not passing in the current url to the getCookies function

depicts avatar Oct 17 '21 21:10 depicts

So the issue only seems to happen when using in a .js file. If you copy my snippet and save to a .js you can reproduce the error. With the .ts sample seems to work fine.

fpena06 avatar Oct 21 '21 21:10 fpena06