XHR headers not sent, misspelled headers options in util.fetchFile
See original GitHub issueWavesurfer.js version(s): 4.0.1 Browser and operating system version(s): Firefox, Ubuntu 20.04 Code needed to reproduce the issue:
this.wave = WaveSurfer.create({
container: '#waveform',
waveColor: '#3f51b5',
progressColor: 'blue',
xhr: {
[{ key: 'Authorization', value: 'Bearer token' }]
}
});
No header sent in request. Checked the code and getArrayBuffer function calls util.fetchFile with options containing params.xhr ( containings headers )
getArrayBuffer(url, callback) {
let options = Object.assign(
{
url: url,
responseType: 'arraybuffer'
},
this.params.xhr
);
const request = util.fetchFile(options);
...
}
when checking util.fetchFile i see it looks for options.requestHeaders, instead of options.headers i think.
// check if headers have to be added
if (options && options.requestHeaders) {
// add custom request headers
options.requestHeaders.forEach(header => {
fetchHeaders.append(header.key, header.value);
});
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
`xhr.getAllHeaders()` is missing some headers in a browser ...
I am working on a browser extension. In a script running on the popup page, I am making an ajax request. On the...
Read more >List of HTTP header fields - Wikipedia
HTTP header fields are a list of strings sent and received by both the client program and server on every HTTP request and...
Read more >That's so fetch! - JakeArchibald.com
This is because it's a CORS request and the response doesn't have CORS headers. However, with fetch, you can make a no-cors request:....
Read more >XMLHttpRequest Standard
During this state request headers can be set using setRequestHeader() and the fetch can be initiated using the send() method. headers received ...
Read more >Using Fetch | CSS-Tricks
Ajax is a technique to send and retrieve information. ... The second option is to set your headers. Since we're primarily sending JSON...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not a bug but a doc mistake. as you said the right option to use is xhr: { requestHeaders: {} } and not xhr: { headers: {} } I changed it in my code and now my keys are sent.
Documentation > Options > xhr