0

I am attempting am building a map data React app using GIS data. I am accessing public GIS endpoints.

The endpoint is http://gis.infrastructure.gov.au/infrastructure/rest/services/KeyFreightRoute/KFR/MapServer/0

On local development, it is working fine. However, once pushed to live it returns the error: net::ERR_CONNECTION_REFUSED. Due to it being an HTTP endpoint.

The ArcGIS docs describe a solution using config, and I have included the following code:

        esriConfig.request.interceptors.push({
          // set the `urls` property to the URL of the FeatureLayer so that this
          // interceptor only applies to requests made to the FeatureLayer URL
          urls: featureLayerUrl,
          // use the BeforeInterceptorCallback to check if the query of the
          // FeatureLayer has a maxAllowableOffset property set.
          // if so, then set the maxAllowableOffset to 0
          before: function (params) {
            if (params.requestOptions.query.maxAllowableOffset) {
              params.requestOptions.query.maxAllowableOffset = 0;
            }
          },
          // use the AfterInterceptorCallback to check if `ssl` is set to 'true'
          // on the response to the request, if it's set to 'false', change
          // the value to 'true' before returning the response
          after: function (response) {
            if (!response.ssl) {
              console.log('not ssl');
              response.ssl = true;
            }
          },
        });

However, it still isn't working!? In fact, the console.log('not ssl') isn't even logging on the live site (but it is logging on localhost).

How do you access HTTP GIS endpoints?

1 Answer 1

2

This is more of a browser limitation than a GIS-specific problem. If your current URL bar has "HTTPS", the page is not allowed to access HTTP resources - the browser enforces this as a security measure. You have two options:

  1. Convince the owner of that site ("gis.infrastructure.gov.au") to enable HTTPS. This is standard practice these days and fairly trivial to do. They should do this.
  2. You can run a proxy like the Esri Resource Proxy on your own server. That way your application will access the url via HTTPS (because your server is secured with HTTPS), but then the server makes the HTTP request on the server site, thus getting around the browser security limitation

Not the answer you're looking for? Browse other questions tagged or ask your own question.