0

I´m trying to access a WMS from statistik.at. Everything is working fine, when i use a browser extension that disables CORS errors, but as soon as I deactivate it i get the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.statistik.at/gs-inspire/VIEW_PD_POPREG_500M/ows?SERVICE=WMS&VERSION=1.3.0&service=WMS&version=1.1.1&request=GetMap&styles=&format=image%2Fjpeg&layers=PD.StatisticalDistribution&bbox=90%2C0%2C180%2C90&width=256&height=256&srs=EPSG%3A4326. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

So, I´ve tried to set the missing header:

new WebMapServiceImageryProvider({
url: new Resource({
  url:
    'https://www.statistik.at/gs-inspire/VIEW_PD_POPREG_500M/ows?SERVICE=WMS&VERSION=1.3.0',
  headers: {
    ‘access-control-allow-origin’: 'www.statistik.at',
    },
  }),
  layers: ‘PD.StatisticalDistribution’,
});

But the behaviour of setting access-control-allow-origin is rather unexpectable, because it set´s the following header:

Access-Control-Request-Headers: access-control-allow-origin

which makes every single request invalid…

I hope that someone can help me out! looking forward for any ideas.

Thank you

  • `access-control-allow-origin` is a **response** header, not a request header. If you want your JS to have permission to access `www.statistik.at` then `www.statistik.at` has to grant permission, your JS can't grant itself permission. That would be pointless. – Quentin Apr 01 '21 at 09:28

1 Answers1

-1

Maybe this similar question can help you. It works for me(In my case, I was loading with Terrain data using Cesium, where Terrain data was published by Tomcat on the server side. Then I encountered CORS error when accessing Terrain data. This problem solved my error). https://gis.stackexchange.com/questions/315967/i-cant-see-my-wms-layer-on-cesium-globe-scene

Dharman
  • 30,962
  • 25
  • 85
  • 135
wbb472
  • 1