Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: auth header doubling in codegen

Andrew Bastin58e940d1933b
diff --git a/helpers/codegen/codegen.ts b/helpers/codegen/codegen.ts
index ab6d21d8f..45baf2d6f 100644
--- a/helpers/codegen/codegen.ts
+++ b/helpers/codegen/codegen.ts
@@ -142,10 +142,20 @@ function getCodegenGeneralRESTInfo(
urlObj.searchParams.append(key, value)
})
+ // Remove authorization headers if auth is specified (because see #1798)
+ const finalHeaders =
+ request.auth.authActive && request.auth.authType !== "none"
+ ? request.effectiveFinalHeaders
+ .filter((x) => x.key.toLowerCase() !== "authorization")
+ .map((x) => ({ ...x, active: true }))
+ : request.effectiveFinalHeaders.map((x) => ({ ...x, active: true }))
+
+ console.log(finalHeaders)
+
return {
name: request.name,
uri: request.effectiveFinalURL,
- headers: request.effectiveFinalHeaders.map((x) => ({ ...x, active: true })),
+ headers: finalHeaders,
params: request.effectiveFinalParams.map((x) => ({ ...x, active: true })),
method: request.method,
url: urlObj.origin,