Cookie handling for fetch in Node.js - small CookieJar plugin for Luminara #179949
Unanswered
miller-28
asked this question in
Programming Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
For anyone building on top of
fetchin Node.js or server side environments and struggling with cookies, I released a small plugin that might help.In the browser, cookies are handled for you.
On the server, if you use
fetch(Node 18+ orundici), you need to:Set-CookieheadersCookieheader per requestI built luminara-cookie-jar, a CookieJar plugin for my HTTP client Luminara, to solve this in a clean way using
tough-cookie.Key points:
Set-Cookiecapture on responsesCookieinjection on requestsCookieJarAPI exposed viaclient.jarfor advanced useMinimal example:
Repo: https://github.com/miller-28/luminara-cookie-jar
npm: https://www.npmjs.com/package/luminara-cookie-jar
If you are using
fetchon the server and need browser-like cookie behavior, this might be useful.Beta Was this translation helpful? Give feedback.
All reactions