AnsweredAssumed Answered

"Unable to load /proxy/?http://localhost Statu 404

Question asked by jsn on Dec 7, 2016
Latest reply on Dec 12, 2016 by rscheitlin

Hello everyone,

I am getting the following error message

"Unable to load /proxy/?http://localhost/FindNextVALUENumber/api/value status: 404"

when running this sample:

https://developers.arcgis.com/javascript/3/jssamples/data_requestJson.html

 

When I pass these URLs, the first one works fine but the second one fails

url = "http://localhost:59297/api/value";   <ç========WORKS FINE – it is the Visual Studio 2012 proejct

 

Or

url = "http://localhost/FindNextVALUENumber/api/value"; <ç==== FAILS – runs from IIS

The second URL is the IIS Application pointing to the same folder.

 

I am using the proxy server from this sample: https://github.com/Esri/resource-proxy

 

I tested both url and they work fine with the proxy:

http://localhost/proxy/proxy.ashx?http://localhost:59297/api/value

 http://localhost/proxy/proxy.ashx? http://localhost/FindNextVALUENumber/api/value

 

 

Here is the proxy.config file

 <ProxyConfig allowedReferers="*"   mustMatch="true">

   <serverUrls>

     <serverUrl url="http://localhost:61004"

                 matchAll="true"/>

 

     <serverUrl url="http://localhost:59297"

               matchAll="true"/>

 

     <serverUrl url="http://localhost"

                   matchAll="true"/>

   </serverUrls>

</ProxyConfig>

 

 

My code:

            esriConfig.defaults.io.proxyUrl = "/proxy/";

 

           var url = "http://localhost:59297/api/value";

           url = "http://localhost/FindNextVALUENumber/api/value";

 

           dom.byId("url").value = url;

           dom.byId("content").value = "";

           //handle the Go button's click event

           on(dom.byId("submitRequest"), "click", getContent);

           var serviceDescriptionStr = "";

           function getContent() {

               var result = "";

               var contentDiv = dom.byId("content");

               contentDiv.value = "";

               domClass.remove(contentDiv, "failure");

               dom.byId("status").innerHTML = "Downloading...";

 

               var requestHandle = esriRequest({

                    "url": url,

                   handleAs: "json"

 

                 });

                                       

               requestHandle.then(

                                 function (response) {

 

                                     console.log("Data: ", response);

                                     dojoJson.toJsonIndentStr = " ";

                                     console.log("Success: ", response);

                                 },

                                 function (error) {

                                      console.log("Error: ", error.message);

                                     alert(error.message);

                                });

            }

Outcomes