A community-supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit - https://cmv.io/
topic.publish("attributesContainer/selectTab", "yourID");
Hi All, I recently discovered using the cacheBust property in the dojo config makes requests fail to https://epsg.io/ (street view widget) because cachebust appends a query string to each request and epsg.io doesn't like that. My temporary solution was to add a ? to the request in the street view widget (getStreetView function)
see below
var key = this.proj4Catalog + ':' + String(wkid);
if (!proj4.defs[key]) {
var url = this.proj4CustomURL || this.proj4BaseURL + String(wkid) + '.js?'; //added question mark for cachebust. cachebust appends version number to url like &1.0.0 and https://epsg.io does not like this! kj 12/30/2019
require([url], lang.hitch(this, 'getStreetView', evt, true));
return;
}
Another idea was to use the hostRedirect property in the proxy config since I am proxying this request but that didn't work. not sure why. Anyone else come across this or have any ideas?
Thanks and Happy New Years
@island Are you using the full version of the Esri API (like https://js.arcgis.com/3.31/
)or the compact version (like https://js.arcgis.com/3.31compact/
)? And also which version of the API? Compact has been the default for CMV for years but I have been considering changing that. I've noticed that cacheBust
appears to have been broken in the compact version at v3.22. Whatever is going on there may have led to other undesirable effects as well.
The cacheBust
property can be used a couple of different ways and there are various methods to have it ignored. How exactly are you using it?
window.dojoConfig = {
locale:'en-us',
async: true,
packages: [
{
name: 'viewer',
location: path + 'js/viewer'
}, {
name: 'gis',
location: path + 'js/gis'
}, {
name: 'config',
location: path + 'js/config'
},{
name: 'widgets',
location: path + 'widgets'
},{
name: 'proj4js',
location: path + 'resources'
}, {
name: 'flag-icon-css',
location: path + 'resources'
}
],
cacheBust:'1.0.1'
};
?1.01
.
cacheBust:'?1.0.1
?
??
to most urls which should be fine. might result in &?
for epsg.io which I guess would still break
@kjohnsonGIS I think this might be a better fix specific to the StreetView widget and others that use epsg.io:
var key = this.proj4Catalog + ':' + String(wkid);
if (!proj4.defs[key]) {
var url = this.proj4CustomURL || this.proj4BaseURL + String(wkid) + '.js';
require({cacheBust: false}, [url], lang.hitch(this, 'getStreetView', evt, true));
return;
}
NOTE the additional first parameter sent to require()
1.0.1
parameter from that point forward for all requests.
@kjohnsonGIS : Capturing for future reference but maybe you can test to be sure.
This appears to work when placed in index.html
(not app.js). With this additional function, the cacheBust
property is not required.
window.dojoConfig = {
locale: locale,
async: true,
fixupUrl: function (url) {
return url + '?1.0.1';
}
};
This function is supported in dojo but not well documented.
?
somewhere else in the url? That's one way to accidentally break the dojo code for using the cacheBust
property and the only reason I can see why it would add &
instead of ?
. The function above circumvents that check but still imperfect.
that's likely the problem then - a compatibility issue with the Esri proxy and cacheBust
parameter that confuses espg.io (and potentially other urls that you do not happen to be accessing)
You might want to consider changing your configuration so the esri proxy is only used for certain domains and not others (like epsg.io). That can be done in viewer.js
using esri/urlUtils
. That's generally a good idea overall though I also recognize that it may not be possible /practical in your implementation.