Survey123 Web - Enable CORS requests by using a proxy in the Survey123 web site

3024
7
11-24-2020 07:57 AM
Status: Closed
Labels (2)
PatriceLabbé
Occasional Contributor

Hi,

In order to be able to use third-party web services in Survey123, all requests to web services should use a proxy deployed in the Survey123 website to avoid CORS requests in Survey123 web forms. At least, it should be configurable.

Some servers don't allow CORS requests. There are no problems when using the Survey123 mobile app. CORS requests occur only with web forms.

ArcGIS Online is working fine with those third-party web services by the way. So I suppose requests are sent with a proxy. Please use same kind of solution for Survey123 web forms.

Thank you!

7 Comments
JamesTedrick

Hi @PatriceLabbé ,

 

Can you provide an example of the type of resource you are wanting to proxy?  In general, the better pattern would be for the server to emit the proper CORS header for access - that way the server's administrator knows how the resource is being used.

PatriceLabbé

Hi @JamesTedrick ,

Here is an example of a tile service we need to use in our Survey123 web forms as a basemap : https://geoegl.msp.gouv.qc.ca/carto/wmts/1.0.0/carte_gouv_qc_public/default/EPSG_3857/{level}/{row}/...

As I said, it's fully working in ArcGIS Online (by adding a new Tile service - not an WMTS service) and with other applications.

Example of a request in Experience Builder (where we see that a proxy is used - we need this in Survey too!!!) :

Experience BuilderExperience Builder

Error in Survey123 web form :

Survey123 errorSurvey123 error

 

JamesTedrick

Thanks for the details,

I see that this service was involved in an earlier support case that led to BUG-000132262.  It would still be the best practice to have the GeoMSP team have CORS properly configured so that their services can be used as resources by others; if you have a contact with that team I would encourage you to mention this.  This is directly related to changes in the ArcGIS JSAPI (not all apps will automatically compensate).  That being said, adding a proxy for these types of resources (as ArcGIS Online has on it's main portal) can be considered.

PatriceLabbé

Hi @JamesTedrick ,

Any update on this?

Thanks!

JamesTedrick
Status changed to: Closed

There are no plans to offer a proxy attached to the Survey123 website.

Esri is actively moving away from implementing proxy technologies to work around CORS limits because of the high adoption rate of CORS across the industry in both browsers and servers. We encourage data providers to support CORS as part of their modernization efforts.

PatriceLabbé

Hi @JamesTedrick ,

Does ESRI is moving away also for ArcGIS Online, Experience Builder, etc? Remember that CORS requests are working fine with those products. What will be the solution in those cases?

I think some providers won't support CORS for security issues.

Thanks!

ArieClaassens1

I found a workaround for Windows Server 2022 and Survey123 website (v3.17 I believe is the latest version, which I installed), using tips from https://www.c-sharpcorner.com/article/enable-cors-4-in-iis-10/ .

  1. Install the IIS 10 CORS module.
  2. Create a basic web.config file to place in your IIS server web root folder, e.g. c:\inetpub\wwroot\
  3. Restart IIS

The format of the web.config I applied successfully (add the required indentation which was stripped off by the text editor in this forum) is:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<cors enabled="true" failUnlistedOrigins="true">
<add origin="*" />
<add origin="https://yourportaldomain"
allowCredentials="true"
maxAge="120">
<allowHeaders allowAllRequestedHeaders="true">
</allowHeaders>
</add>
<add origin="https://yoursurvey123website:5443"
allowCredentials="true"
maxAge="120">
<allowHeaders allowAllRequestedHeaders="true">
</allowHeaders>
</add>
<add origin="http://*" allowed="false" />
</cors>
</system.webServer>
</configuration>

Add the required FQDNs or internal network names for your ArcGIS Servers as needed to this list and adjust the parameters of the add lines as needed.