Good morning.
I am implementing a proxy to my application so that the user does not have to enter login/password every time he wants to enter the application.
I have the application downloaded and implemented on my local server.
I have checked that the webmap is shared with the Organization as well as the layers it has published.
I am using Xammp's Apache server and the proxy chosen was the PHP version offered by ESRI.
GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP.
First I configured the proxy.config:
<SPAN class="php token"><SPAN class="delimiter token"><?</SPAN>xml version<SPAN class="operator token">=</SPAN><SPAN class="string token">"1.0"</SPAN> encoding<SPAN class="operator token">=</SPAN><SPAN class="string token">"utf-8"</SPAN> <SPAN class="delimiter token">?></SPAN></SPAN>
<SPAN class="operator token"><</SPAN>ProxyConfig allowedReferers<SPAN class="operator token">=</SPAN><SPAN class="string token">"*"</SPAN>
logFile<SPAN class="operator token">=</SPAN><SPAN class="string token">"proxy_log.log"</SPAN>
mustMatch<SPAN class="operator token">=</SPAN><SPAN class="string token">"true"</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="markup token"><SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>serverUrls</SPAN><SPAN class="punctuation token">></SPAN></SPAN></SPAN>
<SPAN class="operator token"><</SPAN>serverUrl url<SPAN class="operator token">=</SPAN>"https<SPAN class="punctuation token">:</SPAN><SPAN class="comment token">//MY_ORGANIZATION.maps.arcgis.com/" </SPAN>
username<SPAN class="operator token">=</SPAN><SPAN class="string token">"USER"</SPAN>
password<SPAN class="operator token">=</SPAN><SPAN class="string token">"PASSWORD"</SPAN>
matchAll<SPAN class="operator token">=</SPAN><SPAN class="string token">"true"</SPAN><SPAN class="operator token">/</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="operator token"><</SPAN>serverUrl url<SPAN class="operator token">=</SPAN>"http<SPAN class="punctuation token">:</SPAN><SPAN class="comment token">//services.arcgisonline.com" </SPAN>
matchAll<SPAN class="operator token">=</SPAN><SPAN class="string token">"true"</SPAN><SPAN class="operator token">/</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="markup token"><SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>serverUrls</SPAN><SPAN class="punctuation token">></SPAN></SPAN></SPAN>
<SPAN class="markup token"><SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>ProxyConfig</SPAN><SPAN class="punctuation token">></SPAN></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Second I configured the config.json:
<SPAN class="string token">"wabVersion"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"2.12"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"isWebTier"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"httpProxy"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="string token">"useProxy"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"alwaysUseProxy"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"url"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"PHP/proxy.php?"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"rules"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN>
<SPAN class="string token">"urlPrefix"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"http://MY_ORGANIZATION.maps.arcgis.com/"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"proxyUrl"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"PHP/proxy.php?"</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>The application loads correctly without asking for username/password.
However it does not load the features.
Access to XMLHttpRequest at <SPAN class="string token">'https://static.arcgis.com/attribution/World_Imagery?f=json'</SPAN> <SPAN class="keyword token">from</SPAN> origin <SPAN class="string token">'http://localhost'</SPAN> has been blocked by CORS policy<SPAN class="punctuation token">:</SPAN> The value <SPAN class="keyword token">of</SPAN> the <SPAN class="string token">'Access-Control-Allow-Origin'</SPAN> header <SPAN class="keyword token">in</SPAN> the response must not be the wildcard <SPAN class="string token">'*'</SPAN> when the request<SPAN class="string token">'s credentials mode is '</SPAN>include'<SPAN class="punctuation token">.</SPAN> The credentials mode <SPAN class="keyword token">of</SPAN> requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute<SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Access to XMLHttpRequest at <SPAN class="string token">'https://services9.arcgis.com/YJdM1D4Nb7rZFsXe/arcgis/rest/services/Viviendas/FeatureServer/0?f=json'</SPAN> <SPAN class="keyword token">from</SPAN> origin <SPAN class="string token">'http://localhost'</SPAN> has been blocked by CORS policy<SPAN class="punctuation token">:</SPAN> The value <SPAN class="keyword token">of</SPAN> the <SPAN class="string token">'Access-Control-Allow-Origin'</SPAN> header <SPAN class="keyword token">in</SPAN> the response must not be the wildcard <SPAN class="string token">'*'</SPAN> when the request<SPAN class="string token">'s credentials mode is '</SPAN>include'<SPAN class="punctuation token">.</SPAN> The credentials mode <SPAN class="keyword token">of</SPAN> requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute<SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Services that are not displayed return an error of the type:
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"error"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"code"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">499</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"message"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">"Token Required"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"messageCode"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">"GWM_0003"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"details"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Token Required"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>I don't know if the mistake can come from:
1) I haven't introduced any service in the "proxy.config" so that it passes with the proxy and the features are displayed.
2) When entering username/password I have to change another parameter that I don't know what it can be.
Any idea? Thank you very much in advance