This repository was archived by the owner on Sep 25, 2021. It is now read-only.
This repository was archived by the owner on Sep 25, 2021. It is now read-only.
Open
Description
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?