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 #31

Closed therter closed 5 years ago

therter commented 5 years ago

Please add the Access-Control-Allow-Origin header to the meteogrid wms, because at the moment we get the following error, when an image of a map with overlay layers from the meteogrid wms will be created.

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

ghilbrae commented 5 years ago

So you can see the layers but not add them to a report?

Can you please send me a link or something so I can test it? I'll let you know when it's working.

therter commented 5 years ago

So you can see the layers but not add them to a report?

Yes

Can you please send me a link or something so I can test it? I'll let you know when it's working.

Open the url https://csis.myclimateservice.eu/study/1/step/2/view/maps , add an overlay layer to the map and click on the "Include in Report" button. The created image will be shown on the Summary tab. But I am not sure, if the preparations are done on the csis server.

@patrickkaleta: Have you already set the allowTaint and useCORS options on the server, so that @ghilbrae can test the button?

patrickkaleta commented 5 years ago

@therter yes, I already added the allowTaint option to our button.

@ghilbrae, @therter
cors-error Above you see the error messages (1. and 3. ones mention the CORS settings) I receive when selecting a layer and clicking the "Include in report button". Opening the mentioned link in a separate browser tab works without any problems.

However, I'm not fully sure if there is any action required from @ghilbrae, since I'm able to use hmtl2canvas with that mentioned link in this CodePen example I found, which addresss the same problem we have. Just change the source attribute to one of the meteogrid-links we use and you'll see that it is able to get the requested resource (CodePen example uses same html2canvas version we are, I checked that).

So, my believe is that we need to configure the CORS settings on our server. I'm not an expert on that kind of server configuration, so maybe @Itsman-AT can take care of that?

ghilbrae commented 5 years ago

OK, just let me know. I will not change anything until you're positive that I need to change the server config.

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

Layers are loaded by leaflet.js XHR request, so it's not the same as the code pen example.

For EMIKAT WMS layers it worked after Heinrich added the CORS header to EMIKAT WMS, right @thorsten?

So @ghilbrae just has to add the same header on the METEOGRID Geoserver, that's all. No changes to CSIS configuration required.

Itsman-AT commented 5 years ago

So @ghilbrae just has to add the same header on the METEOGRID Geoserver, that's all. No changes to CSIS configuration required.

So, no action required for the server config at AIT?

therter commented 5 years ago

For EMIKAT WMS layers it worked after Heinrich added the CORS header to EMIKAT WMS, right

Yes, I have tested this locally and it worked with the CORS headers

humerh commented 5 years ago

I added (activated) the following lines in the file (Tomcat)/webapps/geoserver/WEB-INF/web.xml:


>    <filter>
>         <filter-name>CorsFilter</filter-name>
>         <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
>        <init-param>
>            <param-name>cors.allowed.origins</param-name>
>            <param-value>*</param-value>
>        </init-param>
>        <init-param>
>            <param-name>cors.allowed.methods</param-name>
>            <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
>        </init-param>
>        <init-param>
>            <param-name>cors.allowed.headers</param-name>
>            <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
>        </init-param>
>        <init-param>
>            <param-name>cors.exposed.headers</param-name>
>            <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
>        </init-param>
>        <init-param>
>            <param-name>cors.support.credentials</param-name>
>            <param-value>true</param-value>
>        </init-param>
>        <init-param>
>            <param-name>cors.preflight.maxage</param-name>
>            <param-value>10</param-value>
>        </init-param>
>     </filter>
>

plus:

>    <filter-mapping>
>         <filter-name>CorsFilter</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
> 
ghilbrae commented 5 years ago

@therter this should be working now. Let me know if you still have any problems.

I've tested the map you pointed out and the "report button" has worked just fine.

therter commented 5 years ago

@ghilbrae your service works fine now. There is still another problem, but that has nothing to do with your WMS and can be fixed by @patrickkaleta and me

therter commented 5 years ago

Since the other problem has nothing to do with the CORS policy, we can close this issue.