CORS issue with WebTileLayer

4536
20
Jump to solution
09-19-2019 02:13 AM
MatthieuThery3
New Contributor

Hi,

I'm trying to add a layer to my webmap using WebTileLayer and am getting a CORS error message.

Our domain is being  

Our server is CORS enabled. I tried to add the url to the trusted servers.  I tried adding the Tile Layer using leaflet and it works ok. I tried doing it in the API sandbox, I'm getting CORS messages as well.

Here is the urlTemplate: https://{subDomain}.tiles.openrailwaymap.org/standard/{level}/{col}/{row}.png

Any ideas?

Tags (2)
0 Kudos
20 Replies
VictorTey
Esri Contributor

The response header contain what the setting on your server is and the request header shows what is being send. They have to match up to avoid CORS error

Hi I am doing this on my mobile phone so I can only search for a example online.

See screenshot below. Request method of type options. There should be a response header and a request header. This is a preflight request

<image1.png>

0 Kudos
MatthieuThery3
New Contributor

Sorry I must be doing something wrong, but I don't have any OPTIONS request in my network tab. They're all GET. I tried in every browser.

0 Kudos
VictorTey
Esri Contributor

It should be initiated at the beginning before all the actual request.

0 Kudos
MatthieuThery3
New Contributor

Can't see it. As an example can you see it in the esri sandbox url I posted above?

0 Kudos
VictorTey
Esri Contributor

Hi, if you keep the network tab open and click on f5 to refresh. Then you right click to save as har file, I can have a look.

0 Kudos
MatthieuThery3
New Contributor

There it is.

0 Kudos
VictorTey
Esri Contributor

Hi, looks like it didn't send the preflight request as it is a simple request. I am stumped sorry

0 Kudos
ReneRubalcava
Frequent Contributor

I don't think cors is enabled on the server. I tried a few different ways.

I tried testing with this site https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=https%3A%2F%2Fb.ti... 

But I'm not getting back any response headers for access-control.

I would expect to see something like this.

https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=https%3A%2F%2Fstam...

0 Kudos
MatthieuThery3
New Contributor

They do say that their API allows CORS (although maybe not for the tiles):  OpenRailwayMap/API - OpenStreetMap Wiki 

It did work using Leaflet. Maybe they're just not allowing arcgis somehow.

0 Kudos
ReneRubalcava
Frequent Contributor

It's the WebGL rendering of the 4x API. WebGL requires CORS, and although that doc says it supports it, I don't think it's working. You could probably get around this with a proxy if you really need it.

This works in 3x https://codepen.io/odoe/pen/bGbzwvz?editors=1000  because 3x isn't fully WebGL