Search code examples
jqueryangularjsangularjs-directivedojoarcgis-js-api

How to replace http for https before DOM Construct on load KMZ file with ArcGIS API JS


I have an application and it is loaded with https, this application loads a map with a KMZ file, and the content of that file has external reference to a PNG image that is loaded with http. This causes the page's https to break.

Look at this example of how this is done.

var kmlUrl = "https://s3.amazonaws.com/geodera-bucket/filesds/5c2e82457cd9e62b0a453ce3-1578081436616-bushfireAlert.kmz";
var kml = new KMLLayer(kmlUrl);
map.addLayer(kml);
kml.on("load", function() {
  domStyle.set("loading", "display", "none");
});

https://codepen.io/krekto/pen/NWPYmRb

I want to replace these http references with https before loading external content.

My application uses AngularJS, JQuery and Dojo, the solution can be with any of these technologies.


Solution

  • (answered at duplicate question at https://gis.stackexchange.com/questions/347046/how-to-replace-http-for-https-before-dom-construct-on-load-kmz-file-with-arcgis)

    How about letting the browser do the work by adding this in the head:

    <meta http-equiv="Content-Security-Policy" 
          content="upgrade-insecure-requests">
    

    See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests