I have a website that allows users to add map services. If the map service is within a specified domain, I want it to use the proxy and if it is not, I want it to call the service directly. The services on the specified domain are secured and the proxy is used to request it with the correct credentials. I have implemented this by setting alwaysUseProxy to true. I use esri.setRequestPreCallback and if the requested url is not in the specified domain, I remove the proxy's prefix from the url.
The problem is that when I add the service to the map, all tiles are requested through the proxy. Does anyone know of a work around for this? My proxy will be on a server that will only have access to the specified domain. Thank you.