-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Currently, when there is no registered route handler we bypass the request but we are not passing the headers on the XHR case. That can be solved by setting the request headers into the real request:
// xhrinterceptor
nativeSend(data?: any): void {
const request = new NativeXMLHttpRequest();
request.timeout = this.timeout;
request.onload = () => {
const headers = request
.getAllResponseHeaders()
.split("\r\n")
.reduce((previous, current) => {
const [header, value] = current.split(": ");
return {
...previous,
[header]: value
};
}, {});
const response = new KakapoResponse(
request.status,
request.responseBody,
headers
);
this._handleResponse(response);
};
request.open(this._method, this._url);
// start of the fix
Object.keys(this._requestHeaders).forEach(headerName => request.setRequestHeader(headerName, this._requestHeaders[headerName]))
// end of the fix
request.send(data);
}
}cc @mtscrb
Metadata
Metadata
Assignees
Labels
No labels