fix(tracker): fix fetch proxy headers check

This commit is contained in:
nick-delirium 2023-08-21 12:29:43 +02:00
parent 5ea745c14b
commit df4cac4bde
3 changed files with 8 additions and 2 deletions

View file

@ -1,3 +1,7 @@
# 9.0.5
- same fixes but for fetch proxy
# 9.0.2 & 9.0.3 & 9.0.4
- fixes for "setSessionTokenHeader" method

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "9.0.4",
"version": "9.0.5",
"keywords": [
"logging",
"replay"

View file

@ -147,14 +147,16 @@ export class FetchProxyHandler<T extends typeof fetch> implements ProxyHandler<T
if (argsList[1] === undefined && argsList[0] instanceof Request) {
return argsList[0].headers.append(name, value)
} else {
if (!argsList[1]) argsList[1] = {}
if (argsList[1].headers === undefined) {
argsList[1].headers = {}
argsList[1] = { ...argsList[1], headers: {} }
}
if (argsList[1].headers instanceof Headers) {
argsList[1].headers.append(name, value)
} else if (Array.isArray(argsList[1].headers)) {
argsList[1].headers.push([name, value])
} else {
// @ts-ignore
argsList[1].headers[name] = value
}
}