4.7 - I need to add "http://localhost:44300" into CORS policy for debug my project.

6185
17
05-13-2018 11:18 PM
TubaKumbara
Occasional Contributor

Hello.

I'm developing sceneView application and i can't see basemaps when i debugging my project on localhost (pressing F5). Because CORS policy blocking my localhost. But i see no error when i published my project.

I tried to add

esriConfig.request.corsDetection = false;

But doesn't worked.

AccessTo image at "https://myproxyserver/resource-proxy/proxy.ashx?http://myserver.com/myservice/3/5/1.jpg" from origin "https://localhost:44300" has been blocked by CORS policy: No "Access-Contol-Allow-Origin" header is present on the requested ressource. Origin "https://localhost:44300" is therefore not allowed access

Thanks inadvance.

17 Replies
RobertScheitlin__GISP
MVP Emeritus

Tuba,

   You really need to get out of the habit of using localhost. You should use your machine name instead and then make sure you have added your machine name to the proxy.config serverUrls.

0 Kudos
TubaKumbara
Occasional Contributor

thanks for the answer.

ye you're right.

I tried to add below codes into my javascript file

urlUtils.addProxyRule ({ urlPrefix: "https://mymachinename", proxyUrl: "https:proxrserver/proxy.ashx"});

and into proxy.config file

<serverUrl url="https://mymachinename" matchAll="true" />

and i changed to Project URL from VB.NET Project Properties with "https://mymachinename"

doesn't worked. same error.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tuba,

   You have to add the port number to the url or else it is seen as a different server. https://mymachinename:44300 needs to be added to the proxy rule and proxy.config

0 Kudos
TubaKumbara
Occasional Contributor

Hi Robert,

i've defined 44300 port as https from IIS manager. mymachinename is my local IIS name not different server.

JS file

urlUtils.addProxyRule ({ urlPrefix: "https://mymachinename:44300", proxyUrl: "https:proxrserver/proxy.ashx"});

proxy.config file

<serverUrl url="https://mymachinename:44300" matchAll="true" />

still getting same error. I just seeing empty globe in sceneview.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tuba,

   Can you post the error again now that you have made these changes? I just can not understand how you would be getting the same exact error now.

0 Kudos
TubaKumbara
Occasional Contributor

Hello,

I'm getting this error on program startup (with sceneview). I'm seeing only white sceneview. "MyCustomTileMap" is my basemap and i can access from MapView without error. This error occurs when i switch to 3D.

Access to image at "http://myproxyserver/mydir/proxy.ashx?http://mymapserver/Maps/MyCustomTileMap/1/2/3.jpg" from Origin "http://mymachinename" has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin "http://mymachinename" is therefore not allowed access.

 

Thanks inadvance.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tuba,

   Notice that the error is using the http protocol not https you added to the proxy. Also the error does not show a port number.

0 Kudos
TubaKumbara
Occasional Contributor

sorry my bad. all adresses started with https not http. just written wrong here. I tried to run my application with 44300 portnumber and added into proxy.config with port. Still getting same error.

Access to image at "https://myproxyserver/mydir/proxy.ashx?http://mymapserver/Maps/MyCustomTileMap/1/2/3.jpg" from Origin "https://mymachinename" has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin "https://mymachinename" is therefore not allowed access.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tuba,

   So are you also forgetting to add the port number when you are editing the error message to post here?.. You should add the serverURL with http and https and the port and without the port for testing in the proxy.config and proxy rules.

0 Kudos