Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation how to add headers to response #687

Open
sebastianesch opened this issue Feb 16, 2024 · 2 comments
Open

Add documentation how to add headers to response #687

sebastianesch opened this issue Feb 16, 2024 · 2 comments
Assignees

Comments

@sebastianesch
Copy link
Collaborator

sebastianesch commented Feb 16, 2024

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

@renejeglinsky
Copy link
Contributor

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é

@sjvans
Copy link
Contributor

sjvans commented Mar 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants