I am trying to add a simple layer of security to my ArcGIS JS app. I do not want to prompt my users for a login to retrieve a token. So instead I pass the username/password inside this PHP proxy: https://github.com/Esri/resource-proxy/tree/master/PHP
This works great for all of my needs EXCEPT when I try to execute the PrintTask. I get a CORS error because the proxy is not getting prepended to the layer URLs inside the "Web Map as JSON" string.
I basically have my AMD javascript set up as follows:
//in init.js
defne(["dojo/ready", "esri/urlUtils", "esri/tasks/PrintTask", "app/myConfig"], function(ready, urlUtils, PrintTask, config){
ready(function(){
urlUtils.addProxyRule({
urlPrefix: "myMachine.org"
proxyUrl: "myMachine.org/proxy/"
});
printTask = new PrintTask(config.helperServices.printUrl); //global
}
//in print.js
//do all my AMD loading stuff...
//within my printLayout: do stuff
var params = new PrintParameters();
params.map = map;
printTask.execute(params, function(){...}
I receive the following error if firebug:
I suppose it is breaking because my async scope/structure. When I prepend the proxy to the urls in REST GP processing task it prints as expected.
Can anyone think of a workaround that would allow me to use the same logic of using this simple proxy.php to pass security credentials that also prepends my proxy to my web map as json url?