CORS Issue when trying to access Public featurelayers

263
7
02-19-2020 01:57 PM
MohamedMezian1
New Contributor II

Hey


We're using the Arcgis Map on our website with the 4.xx arcgis Javascript library, imported into Angular.

Works on most maps but in some cases, while we are trying to load Public maps published by NOAA Office for Coastal Management  we are getting a Cors error. Did they voluntarily block external domains from importing their featurelayer? Isn't their map public, so free to import on other maps ? 

Thanks

Tags (2)
0 Kudos
7 Replies
RickeyFight
MVP Regular Contributor

Mohamed Mezian

What layer are you trying to add? Are you using their rest/services? 

such as:

CoastalBarrierResourcesSystem (MapServer) 

0 Kudos
MohamedMezian1
New Contributor II

Thanks for your prompt answer. I've tried importing this layer :

    public imageLayersImageLayer[] = [{
        url: 'https://www.coast.noaa.gov/arcgis/rest/services/dc_slr/Flood_Frequency/MapServer',
        title: 'Coastal Flooding Frequency'
    }];
Thanks
0 Kudos
MohamedMezian1
New Contributor II

It works in localhost

0 Kudos
RickeyFight
MVP Regular Contributor

Mohamed Mezian

I am not proficient in Angular. 

Are you adding the layer properly? Is this layer an image layer?

how are you adding other layers to your map? Are you using an AGOL map? 

I was able to view the layer in a non angular map.

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Mohamed Mezian,

I have bad experience with Angular cors issue error before and it's turn out working perfectly in dojo and jquery.

And found out Angular http get/post payload and different domain preflight check working differently from other js framework. But I didn't manage to fix that time.

So, You might want to try with normal dojo and figure out whether it is really cors issue or not.

0 Kudos
MohamedMezian1
New Contributor II

Thanks for your responses. What I don't get is other layers seem to load fine. And they work in localhost. 

I am thinking that perhaps they have restricted domain names.

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Mohamed Mezian‌,

Check whether you are using in mixed mode (http/https) ?

Best Regards,

Than

0 Kudos