datatools-ui icon indicating copy to clipboard operation
datatools-ui copied to clipboard

Modification to use Valhalla routing

Open wkulesza opened this issue 1 year ago • 0 comments

Modified for testing (didn't use Flow framework) to use Valhalla routing instead of Graphhopper. To configure, in configurations/default/env.yml add: VALHALLA_URL: "https://valhalla1.openstreetmap.de/route"

This will work with the stock Valhalla demo - please don't use in production.

When you replace this URL with your own hosted version of Valhalla (either in docker from https://github.com/gis-ops/docker-valhalla or standard, compiled from here: https://github.com/valhalla/valhalla) and run Datatools docker with this url, it will end up with CORS errors.

My setup for either Apache or Nginx is using following header set:

location / {
        proxy_pass http://127.0.0.1:8002; // set to your valhalla instance
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';

    if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' 'https://datatools.goeuropa.net';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
        return 204;
    }

wkulesza avatar Oct 08 '24 15:10 wkulesza