title: Bad credentials while using HttpClient Post
body: <p>i have REST API in symfony 3.4 with lexikjwt authentication and FOS bundle. When i do a post request to :</p>
  
  <pre><code>curl -X POST http://127.0.0.1:8000/login_check -d _username=username -d _password=password
  </code></pre>
  
  <p>a token is generated correctly as expected.
  Also when i enter the username and password in localhost:8000/login, a token is also generated.So the API is working.
  But when i try to send a request from my angular 2 frontend using HttpClientModule using this code :</p>
  
  <pre><code> let body = new HttpParams();
     body.set('_username',username);
     body.set('_password',password);
     let headers = new HttpHeaders().append('Content-Type','application/x-www-form-urlencoded');
     this.http.post('http://localhost:8000/login_check',{body},{headers : headers}).subscribe(data =&gt; {
     console.log(data);
  </code></pre>
  
  <p>I have an error {{code : 401 ,message : "Bad credentials"}}.
  But When i use a generated token to make a GET request :</p>
  
  <pre><code>let headers = new HttpHeaders().append('Authorization','Bearer Some_token');
  this.http.get('http://localhost:8000/api/mydata',{headers : headers}).subscribe(data =&gt; { console.log(data)
  </code></pre>
  
  <p>I got the right Json response.</p>
  
  <p>My nelmio_cors config:</p>
  
  <pre><code>nelmio_cors:
      defaults:
          allow_credentials: false
          allow_origin: []
          allow_headers: []
          allow_methods: []
          expose_headers: []
          max_age: 0
          hosts: []
          origin_regex: false
      paths:
            '^/api/':
                          allow_origin: ['*']
                          allow_headers: ['*']
                          allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS']
                          max_age: 3600
            '^/':
                          origin_regex: true
                          allow_origin: ['*']
                          allow_headers: ['*']
                          allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS']
                          max_age: 3600
  </code></pre>
  
  <p>I wonder why my post request is not working. I tried to look an answer to this but to no avail.</p>