Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Request headers #610

Open
ghost opened this issue May 6, 2021 · 0 comments
Open

Request headers #610

ghost opened this issue May 6, 2021 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented May 6, 2021

The documentation says that I can add a header to the request

  var xhr = event.data.xhr
  xhr.setRequestHeader("X-Request-Id", "123...")

But it doesn't work, I get an error:
DOMException: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.
Which makes sense.

Of course I can open a connection and specify the required settings, something like

            let xhr = event.data.xhr;
            xhr.open('GET', event.data.url, true);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.send();

but in this case, when I navigate through the pages, I will constantly send the old requests and immediately get interrupted.

Is there a solution to this problem?

@ghost ghost added the question label May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

0 participants