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

All services providing WMS (other?) resources must implement Access-Control-Allow-Origin header #51

Closed DenoBeno closed 5 years ago

DenoBeno commented 5 years ago

related to: https://github.com/clarity-h2020/data-package/issues/50 Just a reminder: in order for our screenshot function to work, the WMS server must implement Access-Control-Allow-Origin header. 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)