3

I am building a GIS web app based on ArcGis Server but I have a problem with the Firefox browser. I'm developing in JS a GIS web app that allows the user to edit a feature layer (note: calling ArcGis without ESRI ArcGis API for JS).

The HTTP POST request to create a new record in the ArcGIS Server is the following: http://server/arcgis/rest/services/layerName/FeatureServer/0/addFeatures

As the documentation says (http://resources.arcgis.com/en/help/rest/apiref/fsadd.html), the operations that can permanently change the state of your system (add, update, delete) are POST-only operations. Otherwise, an appropriate error message with an error code of 405 (Method not allowed) will be sent to the client.

In Chrome and IE, to run this POST request and to avoid CORS problem, I use a proxy. Firefox instead, in order to determine whether the actual request is safe to send, first "preflight" the POST requests sending an HTTP request by the OPTIONS method to the resource on the other domain.

Considering therefore that the ArcGIS Server accepts only POST requests to add features and considering that Firefox first send an OPTIONS method, I have a problem to edit a feature layer using Firefox. In fact, the following request:

server/arcgis/rest/services/layerName/FeatureServer/0/addFeatures

return an error code of 405 (Method not allowed).

Is there a work-around or a method to fix this problem? Especially considering that maybe one day, other browsers could implement this OPTIONS request for security reasons.

rick
  • 1,869
  • 13
  • 22
  • If your were using the JS API, this might be handled, but since you're not, this is more of a pure IT problem which might be better addressed at StackOverflow. –  Feb 15 '17 at 12:30
  • The problem seems to be with arcgis server so for mne is GIS related – rick Feb 16 '17 at 10:48
  • Other that Access-Control-Allow-Origin: *, what is passed as Access-Control-Allow-Methods and Access-Control-Allow-Headers ? – Luke Feb 16 '17 at 11:35

2 Answers2

0

There are 4 ways to fix your problem and each way is depends on your server architecture. (the 1st way is just config your server, but the other is use the proxy page that now supports for .NET, PHP, Java).

  1. If you can manage the ArcGIS server.
  2. If you can put the proxy page in the same origin as your web server. (This way will fix the problem by use your server to request to another server and there is no CORS problems anymore.)
    • Just follow the steps in this.
  3. If you must put the proxy page in another origin and you can enable CORS on the server that hosted the proxy page.
  4. If you must put the proxy page in another origin, you must edit the proxy page to accept and reply the preflight request first. (This way will allow your server to handles the preflight requests and accepts them first.)
    • Follow the steps in this.
    • After finished the proxy page settings, then you need to edit the proxy page code to accept and reply the preflight requests. Please take a look at this.
0

I don't have any idea why, but this worked in our app.

Our app is written in react, and relies on a seperate backend API.

Unless we defined REACT_APP_API_host & REACT_APP_API_protocol, we get these 405's from the ESRI basemaps.

Stuart Buckingham
  • 1,574
  • 16
  • 25