question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reqheaders ignored

See original GitHub issue

Just hit my head against my monitor for a few minutes on this one… the documented way to match headers seems to have no effect. Whether my request has a header or not, it is matched by this:

nock('http://www.example.com', {
        reqheaders: {
          'authorization': 'Bearer TOKEN'
        }
      })
      .get('/users/52')
      .query(true)
      .reply(200);

But this (which I only found by digging into historical issues) works as I would expect, failing to match when the header is not provided

nock('http://www.example.com')
      .matchHeader('authorization', 'Bearer TOKEN')
      .get('/users/52')
      .query(true)
      .reply(200)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
callaarscommented, Apr 23, 2018

I’m not sure if it is due to SuperAgent, but that wouldn’t surprise me. Although the strange thing is that the headers are sent. Let me investigate a bit more tonight, I might be missing something.

1reaction
callaarscommented, Apr 23, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ignore headers when running a mocked request with ...
Aaccording to the docs, if reqHeaders is not specified, it will skip them. If no request headers are specified for mocking then Nock...
Read more >
Trying to use custom HTTP Request headers is ignored ... - IBM
Trying to use custom HTTP Request headers is ignored for some header Types in HTTP Client Adapter.
Read more >
HTTP | Node.js v19.3.0 Documentation
Ignored when the keepAlive option is false or undefined . Default: 1000 . maxSockets <number> Maximum number of sockets to allow per host....
Read more >
next.config.js: Custom Headers
Headers allow you to set custom HTTP headers on the response to an incoming request on a given path. To set custom HTTP...
Read more >
1138137 – Undefined req.headers.host when using SSL on ...
Moreover, it uses req.path which will ignore query parameters. I have noticed that node.js applications created from Openshift use an old ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found