When trying to send files to my server using a post request, I encountered the following error:
Error: Request header field Content-Type is not allowed by Access-Control-Allow-Headers.
After researching the issue, I added the necessary headers:
$http.post($rootScope.URL, {params: arguments}, {headers: {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
}
However, this new configuration resulted in another error message:
Error: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers
I searched for a solution and found a similar question that was closed before providing a complete answer. Can anyone advise on which headers should be added or removed in this scenario?