From 4e4655b0a2ac19f4bb5278db3c1a319a491c05ea Mon Sep 17 00:00:00 2001 From: Awesome Stickz Date: Sun, 10 Nov 2024 00:28:39 +0530 Subject: [PATCH] refactor(rest): make proxy.authorization optional in CreateRestManagerOptions (#3977) * fix(rest): sending wrong auth header if proxied and no proxy auth is provided * make proxy.authorization optional in CreateRestManagerOptions instead --- packages/rest/src/manager.ts | 2 +- packages/rest/src/types.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index e80c94fcf..f0be03873 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -534,7 +534,7 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage async makeRequest(method, route, options) { if (rest.isProxied) { - if (rest.authorization !== undefined) { + if (rest.authorization) { options ??= {} options.headers ??= {} options.headers[rest.authorizationHeader] = rest.authorization diff --git a/packages/rest/src/types.ts b/packages/rest/src/types.ts index 0052030ff..28acaea0a 100644 --- a/packages/rest/src/types.ts +++ b/packages/rest/src/types.ts @@ -154,12 +154,12 @@ export interface CreateRestManagerOptions { */ baseUrl: string /** The authorization header value to attach when sending requests to the proxy. */ - authorization: string + authorization?: string /** * The authorization header name to use when sending requests to the proxy * * @remarks - * If the `authorization` header is used it will override any authorization that is given even if + * If the header name is set to `authorization`, it will override any authorization that is given even if * the requests uses OAuth2 Bearer tokens / Basic tokens * * @default "authorization" // For compatibility purposes