Click here to Skip to main content
15,347,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to add headers to the http response in an angular application, if the calls are made to fetch details from local json files?

Version: 8 and above.

Note: I have used HttpClient to fetch data from local json file.

What I have tried:

I've tried to use http interceptor, but it adds header to response only after the response have been received and then I've tried to use proxy in angular application using proxy.config.js file, but could not achieve the expected behavior.
Updated 23-May-22 23:42pm
Rajeev Jayaram 16-May-22 6:57am
Why should you add headers to response?
RajamArunachalam 17-May-22 0:53am
In order to avoid security related alerts during penetration testing and to ensure the response is a secured one by setting some headers on it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900