This sample uses a helper method, added at v3.4, that defines a proxy for a set of resources. In this example all requests to route.arcgis.com are routed to the specified proxy url.
esri.addProxyRule({ urlPrefix: "route.arcgis.com", proxyUrl: "/sproxy" });
For demonstration purposes this sample uses a proxy that has been setup to use app logins and OAuth2 so you aren't required to log-in with an ArcGIS Online organizational subscription to run the sample.
<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
mustMatch="false">
<serverUrls>
<serverUrl url="http://gis.fwb.org/"
matchAll="true"/>
<serverUrl url="http://route.arcgis.com"
clientId="pertinent ID is here"
clientSecret="pertinent Secret is here"
oauth2Endpoint="https://www.arcgis.com/sharing/oauth2/token"
rateLimit=600
rateLimitPeriod=600
matchAll="true">
</serverUrl>
<serverUrl url="http://services.arcgisonline.com"
clientId="pertinent ID is here"
clientSecret="pertinent Secret is here"
oauth2Endpoint="https://www.arcgis.com/sharing/oauth2/token"
rateLimit=600
rateLimitPeriod=600
matchAll="true"/>
</serverUrls>
</ProxyConfig>