MapImageLayer converts an HTTP url to HTTPS

571
2
01-22-2020 01:43 PM
SagesNetworks
New Contributor

MapImageLayer converts an http url to https which prevents the layer from correctly loading.  The endpoint is not HTTPS enabled, and the automatic conversion from http to https is preventing the layer from loading.  Can someone please help?  Thanks in advance.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title>MapImageLayer - create dynamic map layers - 4.14</title>
    <link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.14/"></script>

    <style>
      html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; }
    </style>

    <script>
      require([
        "esri/Map", "esri/views/SceneView", "esri/layers/MapImageLayer",
      ], function(Map, SceneView, MapImageLayer) {

        var layer = new MapImageLayer({
          title: "Parcels", 
          sublayers: [{
            id: 0
          }]
        });
        
        layer.url = "http://www.gis.bocc.co.st-johns.fl.us/sjcgis/rest/services/Parcel/MapServer";
        
        var map = new Map({
          basemap: "topo", layers: [layer]
        });

        var view = new SceneView({
          container: "viewDiv", map: map, zoom: 13, center: [-81.6314837, 30.356906]
        });
        
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>
0 Kudos
2 Replies
BenTurrell
Occasional Contributor III

Hi,

Have a look at this config settings. It sets global properties. Specifically have a look at request and the httpsDomains config | ArcGIS API for JavaScript 4.14 

It looks like if you don't specify a httpsDomain then it will try to redirect all requests through https but if you have a httpsDomain configured it will only send links to those https and all http requests will still be sent as http.

Thanks

Ben


If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

SagesNetworks
New Contributor

Ben, Thank you for your answer.  I tried setting httpsDomains to an empty array.  Unfortunately, the request to my domain still went out as https (and not http).  I then tried using interceptors to intercept and rewrite the url from https to http.  This got me further - and I was able to get to the root of the issue.  The issue is that "Mixed Content" is not allowed on the page when the page itself has been loaded over HTTPS.  I believe this is why the ArcGIS JavaScript API is not taking into effect the httpsDomains property being set to an empty array.  Thanks for your help though.  At this point we are considering using a HTTPS Proxy to get to the HTTP based endpoint.

0 Kudos