I am having the same problem and have solved it in another way. I am not sure which one I prefer.My approach is to subclass esri.layers.WMSLayer and override getImageUrl:
getImageUrl: function (extent, width, height, callback) {
// If applicable prefix with proxy url to let proxy handle authentication
if (esri.config.defaults.io.proxyUrl && !this.proxyUrlPrefixed) {
this.getMapURL = esri.config.defaults.io.proxyUrl + "?" + this.getMapURL;
this.proxyUrlPrefixed = true;
}
this.inherited(arguments);
}
The same approach can be used for WMTSLayer by overriding getTileUrl.Does anyone know the reason why WMSLayer and WMTSLayer do not call the proxy when requesting GetMap and GetTile?