D
Deno

help

Oak – ctx.assert with custom response headers

Aabi6/11/2023
Am I doing this wrong? No extra custom headers are being set in the response as far as I can see in cURL:
ctx.assert(
!missingHeaders,
Status.BadRequest,
JSON.stringify({ error: `Required headers missing: ${missingHeaders}` }),
{ expose: true, headers: { "content-type": "application/json", "foo": "bar" } },
);
ctx.assert(
!missingHeaders,
Status.BadRequest,
JSON.stringify({ error: `Required headers missing: ${missingHeaders}` }),
{ expose: true, headers: { "content-type": "application/json", "foo": "bar" } },
);
I also tried doing { headers: new Headers({ ... }) } but it made no difference.

Looking for more? Join the community!