I have a simple Angular application that I am trying to use to post and update to a feature. However when I send the request I get the error:
Access to XMLHttpRequest at 'https://services.arcgis.com/<appid>/ArcGIS/rest/services/<service name>/FeatureServer/0/updateFeatures' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
This is the code I'm using
update(id: number, data: string): Observable < any > {
let params = new HttpParams();
params = params.append('token', this.authService.userCredential.token);
params = params.append('f', 'json');
params = params.append('features', data)
return this.httpClient.post(`${baseUrl}/updateFeatures`, {params: params}
);
The preflight request is being generated and sent automatically by the browser so I don't have any direct control over it. Looking at the network request I can see that the response to the preflight is completely lacking the Access-Control-Allow-Headers parameter which I assume is what is causing the error.