Javascript CORS

354
5
04-14-2020 09:23 AM
HamzaBoudemia
New Contributor II

Hi all, 

I will try to be quick.

I have an ASP.Net application deployed on IIS.

This application use ESRI Javascript 4.14 API to access to a feature layer in ArcGIS Portal.

So far, so good.

In all browsers (dev machines, integration machines, developers machines...), it works fine.

But in one machine, we have CORS error. when I try to debug my Javascript, in the console, I can see following message (translated from french error message) : 

Blocking of a multi-origin request (Cross-Origin Request): the "Same Origin" policy does not allow consulting the remote resource located on URLOfMyFeatureServer/FeatureServer/0.
Reason: CORS request failed.

Has any one ever encountered this problem ?

Thank you in advance

0 Kudos
5 Replies
HamzaBoudemia
New Contributor II

Hi Victor,

Can you please tell me which server should support CORS ? IIS server (hosting the ASP.Net application) or ArcGIS Portal Server (hosting the layers) ?


0 Kudos
Noah-Sager
Esri Regular Contributor

Another option is to try the trustedServers property:

esriConfig.request.trustedServers - API Reference 

HamzaBoudemia
New Contributor II

Thank you for the answer. I think it will be more convenient If this solution works. I will try it today.

HamzaBoudemia
New Contributor II

One more question : can I reproduce this behavior on my machine ? (CORS ERROR).

 

Thanks in advance

0 Kudos