Cookie handling for fetch in Node.js - small CookieJar plugin for Luminara #179949
Replies: 2 comments 1 reply
-
curious does it handle cookies across redirects automatically (similar to browser fetch)? also how iss performance when sharing jars across multiple clients under load? I have seen tough-cookie get a bit heavy in high-throughput cases, so wondering if you’ve optimized that in your implementation. either way this looks like a clean solution to a long-standing Node fetch pain point |
BetaWas this translation helpful?Give feedback.
-
Great question! This is a very practical solution for Node.js cookie handling. A few additional thoughts that might help others:
Your Luminara plugin looks like an excellent abstraction for Luminara-specific needs. The implementation details you shared (automatic Set-Cookie capture, redirect handling) are exactly what teams need for production systems. |
BetaWas this translation helpful?Give feedback.
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.BetaWas this translation helpful?Give feedback.
All reactions