clarity-h2020 / data-package

CLARITY Data Package Specification, Documentation and Examples
https://clarity-h2020.github.io/data-package/
GNU General Public License v3.0
3 stars 3 forks source link

"Include in Report" functionality is blocked by CORS policy (services.clarity-h2020.eu) #50

Closed therter closed 4 years ago

therter commented 5 years ago

Please add the Access-Control-Allow-Origin header to the wms (http://services.clarity-h2020.eu:8080/geoserver/clarity/ows?service=WMS&version=1.0.0&request=GetCapabilities), because at the moment we get the following error, when an image of a map with overlay layers from this wms will be created.

No Access-Control-Allow-Origin' header is present on the requested resource

Perhaps, this comment can help you

p-a-s-c-a-l commented 5 years ago

seems to work now?

negroscuro commented 5 years ago

Where is the access done from? do you have an URL?

IMHO, when CORS errors happens they are because there is an access to a different server from the one providing the website. So this usually iis solved by including CORS headers in the website javascript which is trying to access another server (different domain name or even just different port)

Are you using react right?

negroscuro commented 5 years ago

Usually this is solved by adding the CORS headers which are:

Access-Control-Allow-Origin: https://www.mydomain.com
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type
Content-Type: application/json

I am not sure how exactly do it but it should be something similar to this:

var allowCrossDomain = function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); // allow requests from any other server
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); // allow these verbs
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Cache-Control");

app.use(allowCrossDomain); // plumbing it in as middleware

With the * you are allowing any other server, but you can state specific ones (services.clarity-h2020.eu:8080 in our case)

negroscuro commented 5 years ago

Mmmmh I am checking buy maybe also Geoserver can include CORS policy to allow request from CSIS...

negroscuro commented 5 years ago

I included such CORS policy in our Tomcat configuration, give it a try please and let me know if anything improved.

therter commented 5 years ago

Thank you, now the wms response contains the Access-Control-Allow-Origin header and the "Include in Report" button is working for this wms. So I can close this issue

DenoBeno commented 5 years ago

I have added a "best practice describing how to do this.

therter commented 4 years ago

The Access-Control-Allow-Origin header is not set again. See also here.

p-a-s-c-a-l commented 4 years ago

What is the status? This is also related to https://github.com/clarity-h2020/data-package/issues/66

negroscuro commented 4 years ago

It should be already solved, did you checked?

therter commented 4 years ago

It should be already solved, did you checked?

No, this is not solved, yet. But perhaps this will be solved, when the new geoserver is used.

p-a-s-c-a-l commented 4 years ago

But perhaps this will be solved, when the new geoserver is used.

Yes. I assume that all layer will be served from https://geoserver.myclimateservice.eu/ See also https://github.com/clarity-h2020/data-package/issues/66#issuecomment-627198788

p-a-s-c-a-l commented 4 years ago

@therter did you check the screenshot functionality with the new geo server? Can we close this issue?

therter commented 4 years ago

@therter did you check the screenshot functionality with the new geo server? Can we close this issue?

Yes, I have checked this and it works