I have a login request I am trying to make. I need to make a POST request to the server with some parameters such as username, password, clientId, ect.
Angular 6 code:
let body = new URLSearchParams();
body.set('username', email);
body.set('password', password);
body.set('customerId', environment.customerId);
body.set('grant_type', 'password');
return this.http.post<JWT>(
    this.baseUrl + this.LOGIN_ENDPOINT,
    body.toString(),
    {
      headers: new HttpHeaders({
        'Content-Type': 'text/plain'
      })
    }
)
When I make a POST request, it gets changed to OPTIONS and the browser blocks the response because the Access-Control-Allow-Origin header is not set. However, in the network tab in Inspect Element, the call actually is correct and returns a 200 OK.
I don't have access to change the backend, and the server company is not working with me on it because they can make a request using ajax.
I tried to make the same request, except using jquery and ajax, and it works just fine, the problem seems to be the 'complex request' sent by angular 6.
Ajax code:
$.post("example.com", {
        grant_type: 'password',
        customerId: 'xxx',
        username: 'xxx',
        password: 'xxx'
    });
Ajax code works, Angular code triggers the OPTIONS / Preflight requests
How can I solve this issue?
