Skip to content

Commit

Permalink
fix: handle headers undefined use case
Browse files Browse the repository at this point in the history
  • Loading branch information
sabineschaller committed Mar 7, 2024
1 parent 2c2cee0 commit 78cd73f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/auth/src/signature/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/tests/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function createContextWithSigHeaders<T extends AppContext>(
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({
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/open_payments/auth/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 78cd73f

Please sign in to comment.