corydolphin / flask-cors

Cross Origin Resource Sharing ( CORS ) support for Flask
https://flask-cors.readthedocs.io/en/latest/index.html
MIT License
884 stars 139 forks source link

Exposed headers cannot be accessed in Angular #265

Closed tsaatey closed 4 years ago

tsaatey commented 4 years ago

Hi, I have a flask-restful backend that is serving my Angular frontend. I have installed flask-cors to handle CORS issues, however, I am not able to get my headers with typescript code. E.g. response.headers // returns undefined. Below is my configuration in the Flask app


    expose_headers = ['tm-auth-token', 'refresh_token'])```.
When I check the network tab of Chrome's dev tools, I can see the headers present but they are not attached to the response.

Kindly help me figure this out. Thank you!
corydolphin commented 4 years ago

Hey @tsaatey I'm sorry but I don't have experience with Angular. If you can see the headers being returned in the browser console, then the issue is somewhere between the response parsing and your callsite. It sounds like the API you are using to access the headers is incorrect. I'd check the angular docs. If you can replicate the behavior using a raw XHR or Fetch, I am happy to help.