The preflight is not supposed to happen for simple requests as per the documentation: https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS).
This is indeed the case if I don't put the additional "Authorization" header in the request:
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic _base64_string_"
Without "Authorization" header:
:authority:www.target.com
:method:POST //<----------------This is correct
:path:/oauth2/access_token?client_id=xxx-xxx
:scheme:https
accept:application/json, text/plain, */*
accept-encoding:gzip, deflate, br
accept-language:en-US,en;q=0.8,fr;q=0.6
content-length:79
content-type:application/x-www-form-urlencoded//<----------------This is correct
origin:http://source.com:4200
referer:http://source.com:4200/
With "Authorization" header, OPTIONS method is automatically set:
:authority:www.target.com
:method:OPTIONS //<----------------This is NOT correct, caused by Authorization header
:path:/oauth2/access_token?client_id=xxx-xxx
:scheme:https
accept:*/*
accept-encoding:gzip, deflate, sdch, br
accept-language:en-US,en;q=0.8,fr;q=0.6
access-control-request-headers:authorization
access-control-request-method:POST
origin:http://source.com:4200
referer:http://source.com:4200/
Because of this issue, I am unable to authorize my app, the server response is :
HTTP method 'OPTIONS' is not allowed. Expected 'POST'
So it seems that the "Authorization" header triggers the preflight in CORS. Can anyone shed some light on this please?