Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ilyazub/764ea38378416d406cf2fbfe8f4ce9fb to your computer and use it in GitHub Desktop.
Save ilyazub/764ea38378416d406cf2fbfe8f4ce9fb to your computer and use it in GitHub Desktop.
Reuse `puppeteer` cookies in `tough-cookie` and `got`
@kiranvj
Copy link

kiranvj commented Jan 2, 2021

Thanks for sharing..... it helped.

@allencch
Copy link

allencch commented Jan 6, 2021

To get the cookie in the request header, request.options.headers.cookie instead of gotOptions.

@gandolfi974
Copy link

thanks but i have an error and i don't understand.

/root/cookies.js:4
const got = require('got')
^
error [ERR_REQUIRE_ESM]: require() of ES Module /root/node_modules/got/dist/source/index.js from /root/cookies.js not supported.
Instead change the require of index.js in /root/cookies.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/root/cookies.js:4:13) {
code: 'ERR_REQUIRE_ESM'
}

thanks

@ilyazub
Copy link
Author

ilyazub commented May 31, 2022

@gandolfi974 please provide more context.

  • What Node version do you use?
  • Is your script bundled for the browser?

@gandolfi974
Copy link

gandolfi974 commented May 31, 2022

sorry,
i had to apply this patch "npm install got@11.8.3" to avoid this error.
for google i have this log "CONSENT=PENDING+860; AEC=AakniGNyWD3SnbxUf8IVQWmrUQaARXNLTE5M9pbVBZlRRDFYkBFeTUy7iw; test_cookie=1"

  • Is it correct ?
  • It's not possible to got cookies from website with https

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment