I need to add a proxy for my app for printing and feature layers. I went to this page on how to include a proxy page:Using the proxy | Guide | ArcGIS API for JavaScript , but I need to know how to write one. How would I do that?
Solved! Go to Solution.
You can't. A proxy has to handled server-side. A browser may support CORS and you can get away without one in those cases. You could even check to see if your request is greater than 2000 characters and send the request via POST instead of GET, but if the browser doesn't support CORS, you can't get around it on the client side.
The proxy pages are provided in a handful of languages.
If you want to know how to write your own for a special purpose, you could look over the source code for those projects.
This is an appendix in the book Chris.
I'm using pure HTML5, no DotNet, Java, or PHP. I do have a web.config file and could technically use the DotNet one, but is there information for just pure HTML5?
You can't. A proxy has to handled server-side. A browser may support CORS and you can get away without one in those cases. You could even check to see if your request is greater than 2000 characters and send the request via POST instead of GET, but if the browser doesn't support CORS, you can't get around it on the client side.
Looks like I will use my .NET proxy again. That helped. Thanks. I had hoped to get completely away from .NET, but since I already have proxy pages written, no point in making work for myself.
Since the proxy needs to run in the server context it is easier to just use the .NET one if you already have a .NET web app. If you want a purely JS one you could write one using node and run that on your server though there isnt a node proxy provided by Esri as yet.
Funny you mention node, it's been coming up in the resource proxy for a node version.
node.js proxy page · Issue #63 · Esri/resource-proxy · GitHub
There is apparently a proxy in the geotrigger-js repo, but I've never used it.
geotrigger-js/index.js at master · Esri/geotrigger-js · GitHub
I have one here, but it doesn't do tokens or anything other than proxy the request
Maybe Esri will eventually create one on Github.