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.

Question: Is there a way to exclude headers from being recorded?

See original GitHub issue

I see there are a few ways to exclude specific headers from requesting matching e.g.

    matchRequestsBy: {
      headers(headers) {
        delete headers['auth-token'];
        return headers;
      }
    }
    // OR
    matchRequestsBy: {
      headers: {
        exclude: ['auth-token']
      }
    }

I’m wondering if there is a way to tell Polly not to record excluded headers?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

5reactions
offirgolancommented, Jan 31, 2019

Np! Setting it to an empty string will still send the header in the next release (see #176). I would suggest removing the header from the array entirely.

recording.request.headers = recording.request.headers.filter(({ name }) => name !== 'auth-token'));
1reaction
offirgolancommented, Jan 31, 2019

You have a few options:

  • Use the request & beforeResponse events to remove the headers from the request/response before they are sent out or received
  • Use the beforePersist event to remove it from the will-be persisted recording so that next time it’s replayed, the headers will no longer be sent.
const { server } = polly;

server.any().on('request', req => {
  req.setHeader('auth-token', null);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude header option · Issue #269 · BurntSushi/xsv - GitHub
I work in an industry where CSV is the primary means for transferring data between industry participants. The irony being ALL the CSV...
Read more >
Google Sheets: How to Remove Headers from QUERY Result
Exclude headers from input. First, you can simply exclude the header row from the input and set the third parameter in your QUERY...
Read more >
How to remove some of the headers of an HTTP request?
I need to remove some of the headers, e.g. Accept , Accept-Language , etc. from an HTTP request being sent from iPhone to...
Read more >
remove columns header for every record - SAP Community
I'm just new to Crystal Reports, so please bare with me. I was asked to remove the repeating column headers on every record...
Read more >
In Excel when try to remove data header also removed - Help
In excel sheet I used record macro to filter data.After filter data I removed it and I got pending record.But when I select...
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