Answer the question
In order to leave comments, you need to log in
How to properly work with csrftoken from django in angular2?
Good day,
How to properly work with csrftoken from django in angular2?
So far, so as not to interfere with development, I wrote a skeleton
document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/, "$1");
Answer the question
In order to leave comments, you need to log in
Solved the problem in general terms. True, it was not without a small crutch, but apparently there is no other way so far.
Here, either use the page that will be generated on django by the application for authentication, or when sending the form from the application to angular2, privately generate the form with the same django to correctly receive the token.
Well, thanks to the angular2-cookie package, the access to the token has been replaced with this:
document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/, "$1");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question