Jump to main content

CSRF

Accessing the CSRF token on your front-end.


Get CSRF Token

If you need to submit a POST request to Django manually, you can import and use the following function to get an object containing a key-value pair representing the headers you would need to include in your request. Use the spread syntax to merge it with your other headers if necessary.

<script>
  import { getCsrfTokenHeader } from '@common';
  const tokenHeader = getCsrfTokenHeader();
</script>