on 11-26-2022 11:34 AM
Hi Everyone,
I have a requirement where I need to add below Headers in CAP Service Response.
Please suggest !!!
Best Regards,
Rewati Raman
Hi,
you can also avoid private APIs by using:
req.res.setHeader('header-name', 'header-value')
Kind regards,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ajitkpanda , can you please provide any documentation on the implementation part.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ajitkpanda ,
Thanks for the reply. I have figure out my issue.
I used helmet nodejs module for the headers.
const cds = require("@sap/cds");const proxy = require("@sap/cds-odata-v2-adapter-proxy");const helmet = require("helmet");var cache = require('cache-control');cds.on("bootstrap", app => { app.use(proxy()); app.use(helmet()); app.use(cache({ '/index.html': 1000, '/none/**/*.html': false, '/private.html': 'private, max-age=300', '/**': 500 // Default to caching all items for 500 }));});Hi Rewati,
You can add by using the following methods:
1) req._.odataRes.setHeader
2) req._.res.set('field','value')
Thanks, Ajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.