Skip to content

Instantly share code, notes, and snippets.

@mk123
mk123 / cookies.md
Last active September 21, 2020 16:49
Angular 2 and django integration with CORS and cookies

How to enable cookies when using angular 2 and django rest framework.

To enable cross origin requests i.e. requests from different servers to django rest framwework api we need to use the following library.
Django CORS
The above link will tell you about most of the configurations but misses some of them which I think are specific to angular 2.

Assuming your django server is running on localhost:8000 and angular 2 server is running on localhost:4200 (your servers might be running on different ports so set accordingly, make following changes in setting.py file of your django project.