diff --git a/packages/auth/src/signature/middleware.ts b/packages/auth/src/signature/middleware.ts index b29f91ad9e..cfc797e148 100644 --- a/packages/auth/src/signature/middleware.ts +++ b/packages/auth/src/signature/middleware.ts @@ -19,7 +19,7 @@ function contextToRequestLike(ctx: AppContext): RequestLike { return { url, method: ctx.method, - headers: JSON.parse(JSON.stringify(ctx.headers)), + headers: ctx.headers ? JSON.parse(JSON.stringify(ctx.headers)) : undefined, body: ctx.request.body ? JSON.stringify(ctx.request.body) : undefined } } diff --git a/packages/auth/src/tests/context.ts b/packages/auth/src/tests/context.ts index 78eb9ad784..e9ab37a4c0 100644 --- a/packages/auth/src/tests/context.ts +++ b/packages/auth/src/tests/context.ts @@ -52,7 +52,7 @@ export async function createContextWithSigHeaders( const request = { url, method, - headers: JSON.parse(JSON.stringify(headers)), + headers: headers ? JSON.parse(JSON.stringify(headers)) : undefined, body: JSON.stringify(requestBody) } const sigHeaders = await createHeaders({ diff --git a/packages/backend/src/open_payments/auth/middleware.ts b/packages/backend/src/open_payments/auth/middleware.ts index 45a3665261..74266e13c0 100644 --- a/packages/backend/src/open_payments/auth/middleware.ts +++ b/packages/backend/src/open_payments/auth/middleware.ts @@ -42,7 +42,7 @@ function contextToRequestLike(ctx: HttpSigContext): RequestLike { return { url, method: ctx.method, - headers: JSON.parse(JSON.stringify(ctx.headers)), + headers: ctx.headers ? JSON.parse(JSON.stringify(ctx.headers)) : undefined, body: ctx.request.body ? JSON.stringify(ctx.request.body) : undefined } }