Problem with http/https

5268
15
07-12-2018 10:57 PM
JiriStrnad
New Contributor II

Hi, 

i have configuration file with services. Services are available from unsecure protocol (http - only). 

When i create instance for examle of FeatureLayer, service is called from https. I have in browser CORS enabled (Chrome with plugin), but that would not affect, when service is called from secure protocol. I tried adding the server to config (corsEnabledServer), but not working... I work with API version 4.8. Interesting is, that version 4.7 work.

15 Replies
JonGarrido
New Contributor III

I have had a similar issue when migrating from 4.7 to 4.8. My FeatureLayer services and MapImageServices are redirected to https in a localhost dev environment. To solve it what I have done is to add a fake domain to my hosts file on windows (C:\Windows\System32\drivers\etc)  , for example: 

127.0.0.1 test-ieo.com

Now my dev app is running on test-ieo.com:3000/ in addition to localhost:3000/.  In the test-ieo.com url is working fine!!

I hope this can be useful for someone...

Jon

Stacy-Rendall
New Contributor III

Yes - this solves it! Using this solution: instead of accessing the page through localhost, which evaluates to secure environment and thus upgrades request to HTTPS (which doesn't exist for HTTP services), the fake domain does not evaluate to secure, so doesn't upgrade the request, thus allowing you to access the HTTP service over HTTP. Thanks Jon Garrido!

Stacy-Rendall
New Contributor III

Just be careful to choose a fake domain that either doesn't exist or that you don't care about, as it will override the real domain if you try to go to it...

0 Kudos
DavidSchontzler
New Contributor III

Localhost has been whitelisted in 4.9: Release notes for 4.9 | ArcGIS API for JavaScript 4.9 

RubyStroschein
New Contributor III

Also esri services do not support https and CORS? I can't use Geometry service 

Access to XMLHttpRequest at 'https://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

0 Kudos
sapnas
by
Occasional Contributor III

Have you tried using http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project instead. You need to replace https with http or enable ssl for your local host to access https geometry service

0 Kudos