docs icon indicating copy to clipboard operation
docs copied to clipboard

Add documentation how to add headers to response

Open sebastianesch opened this issue 1 year ago • 2 comments

Hi,

it would be nice to explain in https://github.com/cap-js/docs/blob/main/node.js/events.md#class-cdsrequest--cds-request-, how to return custom response headers.

I think the correct way would be using req.res.setHeader(), but I think from the past, there are a lot of examples in the wild, that use private APIs like e.g. https://community.sap.com/t5/technology-q-a/how-to-add-header-in-cap-service-response/qaq-p/12674871#M4755468 or here https://community.sap.com/t5/technology-q-a/add-response-headers-in-sap-cap/qaq-p/12644749#M4743715.

Kind regards, Sebastian

sebastianesch avatar Feb 16 '24 08:02 sebastianesch

Hi Sebastian, thanks for opening this issue. This topic is in the backlog in conjunction with a planned development in that area. Will update you here when we can provide more information. All the best, René

renejeglinsky avatar Feb 26 '24 07:02 renejeglinsky

hi @sebastianesch @renejeglinsky

i actually created a pr some time ago to remove docs re req._ as i think it's only still there by mistake (can't be found in toc, for example). since a couple of majors, we have req.http, which provides access to the incoming request and outgoing response. i can extend the sample there to include headers (as well as a minor warning regarding /$batch subrequests).

best, sebastian

sjvans avatar Mar 28 '24 18:03 sjvans