jpatokal / openflights

Website for storing flight information, rendering paths on a zoomable world map and calculating statistics, with plenty of free airline, airport and route data.
http://openflights.org
GNU Affero General Public License v3.0
1.37k stars 387 forks source link

OpenLayers zoom control icons not loading for subpages #1465

Open jpatokal opened 4 months ago

jpatokal commented 4 months ago

If you browse to a subpage like https://openflights.org/airport/SIN or https://openflights.org/user/jpatokal, the images for the OpenLayers controls don't load properly:

image

The paths appear to be hardcoded into js/OpenLayers.js as relative paths (img/north-mini.png etc), so it's trying to load things like https://openflights.org/airport/img/zoom-minus-mini.png and failing.

Possible solutions: we can either add redirects/rewrites to img for each of user/img, trip/img, airport/img, and airline/img, or hack the minified JS to make the paths absolute.

I spent some time trying to hack this into the nginx config, but this is not working for reasons I don't understand. Fixes or better ideas?

    location ~ \.png$ {
      rewrite "^/(.+)/img/(.+)$" /img/$2 break;
    }
corywright commented 1 month ago

Another option may be to include a base href:

<base href="https://openflights.org/">

Placing this in the <head> section of the HTML makes all relative paths resolve from the specified base URL.