Select to view content in your preferred language

How do I write a proxy page for an HTML5 application?

1683
7
Jump to solution
11-21-2014 09:11 AM
ChrisSergent
Deactivated User

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?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Esri Frequent Contributor

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.

View solution in original post

7 Replies
ReneRubalcava
Esri Frequent Contributor

The proxy pages are provided in a handful of languages.

Esri/resource-proxy · GitHub

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.

0 Kudos
ChrisSergent
Deactivated User

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?

0 Kudos
ReneRubalcava
Esri Frequent Contributor

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.

ChrisSergent
Deactivated User

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.

0 Kudos
DaveTimmins
Deactivated User

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.

ReneRubalcava
Esri Frequent Contributor

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

agsnode-dev/app.js at master · odoe/agsnode-dev · GitHub

ChrisSergent
Deactivated User

Maybe Esri will eventually create one on Github.

0 Kudos