San

San

  • 781
  • 804
  • 314.4k

CORS sync sends OPTIONS request instead of POST

Jul 31 2019 12:13 PM
I'm trying to use the POST API Call in Angular Component . I got the following request headers which are far from my expectations:
 
Here is a code:
 
postAccount(occount:OAccount){
var body=JSON.stringify(oaccount);
var headerOptions=new Headers({'Content-Type':'application/json'});
var requestOptions=new RequestOptions({method:RequestMethod.Post,headers:headerOptions,withCredentials:true})
return this.http.post(this.API_ENDPOINT + 'OAccount',body,requestOptions).map(x=>x.json());
}
 
Request URL:http://localhost:5000/api/Account
Request method:OPTIONS
Remote address:07.0.0.0:0000
Status code:
401
Version:HTTP/1.1
Referrer Policy:no-referrer-when-downgrade
Response headers (390 B)
Raw headers
Cache-Control
private
Content-Length
6143
Content-Type
text/html; charset=utf-8
Date
Wed, 31 Jul 2019 17:04:16 GMT
Server
Microsoft-IIS/10.0
WWW-Authenticate
Negotiate
WWW-Authenticate
NTLM
X-Powered-By
ASP.NET
X-SourceFiles
=?UTF-8?B?QzpcVXNlcnNcMzUxNzU2…2lvblxhcGlcT3NhQWNjb3VudA==?=
Request headers (417 B)
Raw headers
Accept
*/*
Accept-Encoding
gzip, deflate
Accept-Language
en-US,en;q=0.5
Access-Control-Request-Headers
content-type
Access-Control-Request-Method
POST
Connection
keep-alive
Host
localhost:5000
Origin
http://localhost:4000
Referer
http://localhost:4000/accounts
User-Agent
Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/68.0

Answers (1)