When you deploy an app, you may need to use a proxy. Web AppBuilder supports using proxies in the following situations:
- Accessing cross domain resources
- Requests that exceed 2048 characters
- Accessing resources secured with token based authentication
- OAuth 2.0 app logins
- Enabling logging
- Both resource- and referrer-based rate limiting
By default, the downloaded app's proxy setting is blank. Specify your own proxy and rules by modifying the httpProxy property in the app's config file. The httpProxy property contains the following attributes:
Boolean. Optional. Default: true. If false, all requests will not use a proxy.
String. Optional. The URL to specify the proxy location. If the request doesn't match any proxy rule but must use a proxy, such as a cross domain request, this proxy will be used.
Boolean. Optional. Specifies whether or not the proxy should always be used for communication to a REST endpoint. Default: false. If the request doesn't match any proxy rule and doesn't need a proxy, the app checks this property to determine how to further use the proxy. If false, the request does not go through the url referenced proxy. If true, the request goes through the url referenced proxy.
Object. Optional. Defines the proxy for a set of resources with the same URL prefix. If the request URL matches a rule, the request routes through the proxy. Each rule has two properties:
When useProxy is false and a request is larger than 2048 characters, a POST instead of GET request is sent. Also, if the service supports CORS, the POST request can be sent directly to the service successfully. Otherwise, the POST request fails. When useProxy is true and a POST request is sent, if the service doesn't support CORS, the POST request will be sent by the proxy automatically.
The following demonstrates how proxies work in relation to the above attributes:
- The app checks useProxy.
- If false, all requests do not use a proxy.
- If true, the app checks rules.
- If the request matches the proxy rules, the app uses the proxyUrl set in the rules.
- If the request does not match any proxy rule but has to use a proxy, such as a cross domain request, the app uses the url referenced proxy.
- If the request does not match the proxy rules nor requires a proxy, the app checks alwaysUseProxy further.
- If false, the request does not go through the url referenced proxy.
- If true, the request goes through the url referenced proxy.
In addition, Esri provides three proxies, each targeting a specific server-side platform: ASP.NET, Java/JSP, and PHP. Download and deploy the appropriate proxy for your platform from GitHub. Also, see the Using the proxy examples.