tomas / tomas/needle

Cookies don't send after redirect

Open
#437 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

  const options = {
    follow_set_cookies: true,
    cookies: {
      test: new Date().valueOf()
    }
  };

  const response = await needle('GET', 'https://setcookie.net/', undefined, options);
  console.log(response.body.match(/<code>(.+)<\/code>/i)?.[1]);

  const response2 = await needle('GET', 'https://shorturl.at/BQUI3', undefined, options);
  console.log(response2.body.match(/<code>(.+)<\/code>/i)?.[1]);

The example can looks strange but in real case it's a redirect from www.host.com to host.com

It was broken in 3.1.0 after had added the challenge host_and_ports_match
https://github.com/tomas/needle/blob/9454d7bdc94b5a9a9c8f60eafefb6408f83a9a37/lib/needle.js#L542-L553

https://github.com/tomas/needle/issues/428

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the redirect cookie handling in lib/needle.js at the host_and_ports_match challenge referenced in the issue, then reproduce the two requests against setcookie.net and shorturl.at. Confirm the redirect from www.host.com to host.com preserves the configured and received cookies without regressing host or port checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.