cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Request Headers in CDS for Node.js

SebastianEsch
Active Participant
0 Kudos

Hi CAP Community,

it looks like access to the Request Headers in Custom Event Handlers does not work as documented. Accessing the Headers via req.headers as documented in the Core Services API returns undefined. I have to fall back to the Express Headers accessible via req._.req.headers.

I have setup an example project to demonstrate the issue.

I guess this is a bug?

Kind regards,

Sebastian

Your environment (run the following commands):

  • cds -v
@sap/cds: 4.1.9
@sap/cds-compiler: 1.39.0
@sap/cds-dk: 3.0.0
@sap/cds-foss: 2.0.0
@sap/cds-reflect: 2.13.0
@sap/cds-runtime: 2.3.1
Node.js: v12.16.1
home: /*** removed ***
request-headers: 1.0.0
undefined: -- missing --
  • node -v
v12.16.1
OlenaT
Advisor
Advisor
0 Kudos

Hi Sebastian,

req.headers are not supported yet. We will notify you when the feature will be available.

Best regards,

Olena

Accepted Solutions (1)

Accepted Solutions (1)

heiko_witteborg
Explorer

Hi Sebastian,

https://cap.cloud.sap/docs/node.js/api#req-headers is now supported. Please check with the latest cds version (currently 4.3.0). Of course, please let us know if you still face issues.

Best regards,

Heiko

Answers (0)