fix: import bug with extension and agent interceptors (#4932)
Co-authored-by: curiouscorrelation <curiouscorrelation@gmail.com>
This commit is contained in:
parent
0c361faeab
commit
fb2b677faf
4 changed files with 35 additions and 5 deletions
|
|
@ -205,7 +205,6 @@ declare module 'vue' {
|
|||
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
|
||||
IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default']
|
||||
IconLucideBrush: typeof import('~icons/lucide/brush')['default']
|
||||
IconLucideCheck: typeof import('~icons/lucide/check')['default']
|
||||
IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']
|
||||
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
|
||||
IconLucideCircleCheck: typeof import('~icons/lucide/circle-check')['default']
|
||||
|
|
@ -216,7 +215,6 @@ declare module 'vue' {
|
|||
IconLucideLayers: typeof import('~icons/lucide/layers')['default']
|
||||
IconLucideListEnd: typeof import('~icons/lucide/list-end')['default']
|
||||
IconLucideMinus: typeof import('~icons/lucide/minus')['default']
|
||||
IconLucidePlus: typeof import('~icons/lucide/plus')['default']
|
||||
IconLucidePlusCircle: typeof import('~icons/lucide/plus-circle')['default']
|
||||
IconLucideRss: typeof import('~icons/lucide/rss')['default']
|
||||
IconLucideSearch: typeof import('~icons/lucide/search')['default']
|
||||
|
|
|
|||
|
|
@ -132,8 +132,24 @@ export class AgentKernelInterceptorService
|
|||
.join(";")
|
||||
}
|
||||
|
||||
const existingUserAgentHeader = Object.keys(
|
||||
effectiveRequest.headers || {}
|
||||
).find((header) => header.toLowerCase() === "user-agent")
|
||||
|
||||
// A temporary workaround to add a User-Agent header to the request
|
||||
// This will be removed once the agent is updated to add User-Agent header by default
|
||||
const effectiveRequestWithUserAgent = {
|
||||
...effectiveRequest,
|
||||
headers: {
|
||||
...effectiveRequest.headers,
|
||||
"User-Agent": existingUserAgentHeader
|
||||
? effectiveRequest.headers[existingUserAgentHeader]
|
||||
: "HoppscotchKernel/0.1.0",
|
||||
},
|
||||
}
|
||||
|
||||
const [nonceB16, encryptedReq] = await this.store.encryptRequest(
|
||||
await relayRequestToNativeAdapter(effectiveRequest),
|
||||
await relayRequestToNativeAdapter(effectiveRequestWithUserAgent),
|
||||
reqID
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ export class ExtensionKernelInterceptorService
|
|||
await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({
|
||||
url: request.url,
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
headers: request.headers ?? {},
|
||||
data: requestData,
|
||||
wantsBinary: true,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -83,7 +83,23 @@ export class NativeKernelInterceptorService
|
|||
.join(";")
|
||||
}
|
||||
|
||||
const relayExecution = Relay.execute(effectiveRequest)
|
||||
const existingUserAgentHeader = Object.keys(
|
||||
effectiveRequest.headers || {}
|
||||
).find((header) => header.toLowerCase() === "user-agent")
|
||||
|
||||
// A temporary workaround to add a User-Agent header to the request
|
||||
// This will be removed once the kernel/relay is updated to add User-Agent header by default
|
||||
const effectiveRequestWithUserAgent = {
|
||||
...effectiveRequest,
|
||||
headers: {
|
||||
...effectiveRequest.headers,
|
||||
"User-Agent": existingUserAgentHeader
|
||||
? effectiveRequest.headers[existingUserAgentHeader]
|
||||
: "HoppscotchKernel/0.1.0",
|
||||
},
|
||||
}
|
||||
|
||||
const relayExecution = Relay.execute(effectiveRequestWithUserAgent)
|
||||
|
||||
const response = pipe(relayExecution.response, (promise) =>
|
||||
promise.then((either) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue