Little late to the party,
If you are using Angular 7 (or 5/6/7) and PHP as the API and still getting this error, try adding following header options to the end point (PHP API).
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST, PUT, OPTIONS, DELETE, PATCH");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
Note : What only requires is Access-Control-Allow-Methods
. But, I am pasting here other two Access-Control-Allow-Origin
and Access-Control-Allow-Headers
, simply because you will need all of these to be properly set in order Angular App to properly talk to your API.
Hope this helps someone.
Cheers.