kiwix / kiwix-tools

Command line Kiwix tools: kiwix-serve, kiwix-manage, ...
https://download.kiwix.org/release/kiwix-tools/
GNU General Public License v3.0
433 stars 85 forks source link

kiwix-serve -r (--urlRootLocation) flag failures #521

Closed holta closed 2 years ago

holta commented 2 years ago

This bug does not affect Internet-in-a-Box.

But it's being reported as a service for others, at it suddenly affects all kiwix-tools nightly builds starting with 2022-01-05.

Specifically, kiwix-serve's -r flag (same as the --urlRootLocation flag) adds the specified string into the URL twice, which breaks all links from kiwix-serve's main/welcome page.

Example run: ./kiwix-serve -r foobar phet_en_2021-08.zim

Example broken link: http://192.168.0.100/foobar/foobar/phet_en_2021-08

The correct link would (and should!) be: http://192.168.0.100/foobar/phet_en_2021-08

Recap: this worked in all nightly builds up to and including 2022-01-04.

Related:


ASIDE: when run at the command line, kiwix-serve also advertises the wrong URL, failing to add the string specified by -r = --urlRootLocation

./kiwix-serve -r foobar phet_en_2021-08.zim
The Kiwix server is running and can be accessed in the local network at:
 http://192.168.0.100:80

The correct advertised URL would (and should!) be: http://192.168.0.100:80/foobar

kelson42 commented 2 years ago

@veloman-yunkan @mgautierfr @juuz0 URGENT We really need to fix this bug (if confirmed) before anything else. It seems we have introduced this regression a few days ago.

juuz0 commented 2 years ago

https://github.com/kiwix/libkiwix/commit/66c40817eed316ea79a2f4f01d8be1e2160b6742 introduced this regression.

juuz0 commented 2 years ago

The problem is in line 109 of index.js (libkiwix) where we set href={root}{link} Since https://github.com/kiwix/libkiwix/commit/66c40817eed316ea79a2f4f01d8be1e2160b6742, OPDS stream provides full URL and we dont need to append {root}. Simply removing it will fix the issue.