Im useing a proxy on my webserver, which uses the esri web-adapter, and want to know if I can pre configure the proxy settings in the base code of WAB Developer. Its a bit annoying to have to copy and paste in the proxy settings to every map when I export them at a new version.
Solved! Go to Solution.
Wow thanks to Subu suggesting a JS beautifier I found it pretty quick. I used os.walk python to look in every file for "useProxy" and add any that contained it to a list. Then I just beautified the code in those few files before searching through them. In '\server\rest\apps.js' there is a function called zipApp which does what I expected, edits the app config in the deployment zip. I dont know enough JS to tell if it happens before or after zipping but I plugged 'TEST' into the empty url string, saved, exported and there it is in the config.json in the zipfile. Beautified version below, the url is on line 21.
function zipApp(e, t) { var n = getAppPath(e); n = path.normalize(n); try { fs.existsSync("./apps/zips") || fs.mkdirSync("./apps/zips"); var i = fse.readJsonSync(path.join(getAppPath(e), "config.json")), r = i.portalUrl; "/" !== r.substr(r.length - 1, r.length) && (r += "/"); var o = new JSZip; utils.visitFolderFiles(n, function(e, t, i) { var r, a = e.substr(n.length, e.length); if (i) o.folder(a); else if ("env.js" === a) r = fs.readFileSync(e, { encoding: "utf-8" }), r = r.replace("//apiUrl = ", "apiUrl = "), o.file(a, r); else if ("config.json" === a) { var p = fse.readJsonSync(e); p.httpProxy = { useProxy: !0, alwaysUseProxy: !1, url: "", rules: [] }, p.appId = "", o.file(a, JSON.stringify(p)) } else r = fs.readFileSync(e), o.file(a, r) }); var a = o.generate({ type: "nodebuffer", compression: "DEFLATE" }); fs.writeFileSync(getZipFilePath(e), a, "binary"), t() } catch (p) { console.log(p), t(p) } }
That's what I've been doing at the app level. I am going to try putting the settings in the base config.json in WAB so it gets applied to every new/imported app. I know you can do this with the widgets but I've not tried with that particular config. It'll save about 30 minutes of opening every config and entering the settings.
Maybe you can modify the proxy.js in your server folder?
Hmm that looks like some of the internal workings of the WAB server. I dont see where I could insert the proxy settings. It looks to me like sitemap\config.json is where it should go but in sitemap\copy-list.txt that json file isnt copied to the new apps as they are created/imported. It has to be in there somewhere and I'm determined to dig it out. If that file isnt copied than the config.json in the app folder is freshly created each time, so there must be a default coded in somewhere.
edit: found a clue in client\builder\main.js - nope nevermind.
Chris,
Did you ever sleuth out anything regarding this?
Michael
No, annoyingly. I could find references to it all throughout and could find sample configs but not where the config that gets zipped up with an app for deployment actually gets copied from. Its not the one that lives with the app in the development directories because that one is different and set up specifically to make the app function correctly in the WAB environment. It may be that a piece of code edits that file in place as its being zipped but I cant seem to see it. Much of that code isn't formatted so when you open it in a text editor or IDE its just a big wall of text. It's there somewhere but I never found it.
Thanks Chris.
I'm going to open a call with ESRI tech support and see if we can get this solved.
That would be very helpful. Post the results!
This the info I received from the ESRI support call I made.
"After conferring with Development they've informed me that there are no settings to alter that will allow you to modify the default proxy block in config.json for all apps.
With that in mind there is an alternative option. You could create base 'stock' apps, modify their config.json and then use them as the basis for future applications. Would that be a workable alternative?"