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.

Request headers are cleaned

See original GitHub issue

In the following code, according to the documentation, request headers should be persisted, but they are cleaned after page is refreshed.

<!DOCTYPE html>
<html>
<head>
    <link href="https://unpkg.com/graphiql/graphiql.min.css" rel="stylesheet"/>
</head>
<body style="margin: 0;">
<div id="graphiql" style="height: 100vh;"></div>
<script crossorigin src="https://unpkg.com/react/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/graphiql/graphiql.min.js"></script>
<script>
      function graphQLFetcher(graphQLParams, opts = {headers: {}}) {
        return fetch(
          '/api',
          {
            method: 'post',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/json',
              ...opts.headers
            },
            body: JSON.stringify(graphQLParams),
            credentials: 'omit',
          },
        ).then(function (response) {
          return response.json().catch(function () {
            return response.text();
          });
        });
      }

      ReactDOM.render(
        React.createElement(GraphiQL, {
          fetcher: graphQLFetcher,
          headerEditorEnabled: true,
        }),
        document.getElementById('graphiql'),
      );
</script>
</body>
</html>

headers: an optional GraphQL string to use as the initial displayed request headers, if undefined is provided, the stored headers will be used.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
majkrzakcommented, Jun 25, 2020

shouldPersistHeaders works, but I wonder if would it be possible for headers option to be treated as default when nothing is stored? Currently it always override it.

2reactions
harshithpabbaticommented, Jun 25, 2020

hey @majkrzak, there is a prop shouldPersistHeaders you should enable that to persist your headers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to clean up HTTP headers, sanitize or Res...
It's a bit more clear of a solution as well as the HTTP::header sanitize function allows some headers but not all essential ones....
Read more >
Is there a way to "clean" an accept header in Java?
You can read request headers, and modify response headers in this way (you can not modify request headers, it's a read only map):...
Read more >
Clear-Site-Data - HTTP - MDN Web Docs
The Clear-Site-Data header clears browsing data (cookies, storage, cache) associated with the requesting website. It allows web developers ...
Read more >
HTTP header manipulation - Envoy Proxy
The HTTP connection manager manipulates several HTTP headers both during ... This header is cleaned from external requests, but for internal requests will ......
Read more >
Request headers are cleared after updateData() method call
17 to 2.7.20. Request headers are set in report object using 'requestHeaders' property of the data source. On the first load headers are...
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