title: How to fix "Forbidden (CSRF cookie not set.)"
body: <p>When I send some data from my front-end via axios, my API give error Forbidden (CSRF cookie not set.)</p>
  <p>I use csrf_exempt to avoid this error, however it doesn't help me</p>
  <p><strong>views.py:</strong></p>
  <pre class="lang-py prettyprint-override"><code>@csrf_exempt
  def registration(request):
      if request.method == 'POST':
          data = json.loads(request.body.decode('utf-8'))
          if not is_user_data_valid_for_create(data):
              return HttpResponseBadRequest()
          user_role = Role.objects.get(pk=1)
          user = User.create(
              first_name=data['first_name'],
              last_name=data['last_name'],
              email=data['email'],
              password=data['password'],
              role=user_role
          )
          return HttpResponse(&quot;Success,{} your account created!&quot;.format(user.first_name), status=201)
      return HttpResponseBadRequest()
  </code></pre>
  <p><strong>This is my code on React:</strong></p>
  <pre class="lang-html prettyprint-override"><code>constructor(props) {
          super(props);
  
          this.state = {
              first_name: '',
              last_name: '',
              email: '',
              password: ''
          }
      }
  
      changeHandler = event =&gt; {
          this.setState({[event.target.name]: event.target.value})
      };
  
      submitHandler = event =&gt; {
          event.preventDefault()
          console.log(this.state);
          axios
              .post('http://127.0.0.1:8000/api/v1/user/restration/', this.state)
              .then(response =&gt; {
                  console.log(response)
                  console.log(response.data)
              })
              .catch(error =&gt; {
                  console.log(error)
              })
      };
  
  &lt;form onSubmit={this.submitHandler}&gt;
                  &lt;div className=&quot;user-data&quot;&gt;
                      &lt;div className=&quot;form-group&quot;&gt;
                          &lt;label&gt;First Name&lt;/label&gt;
                          &lt;input type=&quot;text&quot; placeholder=&quot;John&quot; name=&quot;first_name&quot; value={first_name}
                                 onChange={this.changeHandler} className=&quot;form-control&quot;/&gt;
                              &lt;/div&gt;
  ...
                    &lt;div className=&quot;sign-up-w&quot;&gt;
                        &lt;button type=&quot;submit&quot; className=&quot;btn-primary sing-up&quot;&gt;SIGN UP&lt;/button&gt;
                    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>When I send data from UI I have the error:</p>
  <blockquote>
  <p>Forbidden (CSRF cookie not set.): /api/v1/user/restration/</p>
  <p>&quot;POST /api/v1/user/restration/ HTTP/1.1&quot; 403
  2868</p>
  </blockquote>
  <p>However, when I send data via Postman everything is okay.</p>