NatLibFi / Annif

Annif is a multi-algorithm automated subject indexing tool for libraries, archives and museums.
https://annif.org
Other
197 stars 41 forks source link

Fix blocked http-request for version number on https site #773

Closed juhoinkinen closed 7 months ago

juhoinkinen commented 7 months ago

Displaying the version of Annif on Web UI was added in PR #745, but it was not working when Annif was deployed on a site using https, e.g. https://dev.annif.org: Firefox console showed error

Blocked loading mixed active content “http://dev.annif.org/v1/”

and the displayed version string was empty.

~This SO answer advises to add a metatag for "Content-Security-Policy: upgrade-insecure-requests". This "is intended for websites with large numbers of insecure legacy URLs that need to be rewritten", but I did not find another way to fix this, because the version number is queried from /v1 path, whatever the site domain is.~

But now I started to wonder why the same error does not arise when querying projects from /v1/projects path, which is also a GET request...

Edit: Force pushed with a more proper way to fix this by fetching the version information from url /v1/ (with trailing slash), which was hinted in some SO answers. It seemed that directly accessing https://dev.annif.org/v1 with a browser was returned with a 308 Permanent Redirect to https://dev.annif.org/v1/, so it seems the trailing slash "just makes this work", and this is related to the (root) path defined in the OpenAPI spec used for the version, which appends a slash to /v1.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.65%. Comparing base (1e182b2) to head (a81b01a).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #773 +/- ## ======================================= Coverage 99.65% 99.65% ======================================= Files 89 89 Lines 6404 6404 ======================================= Hits 6382 6382 Misses 22 22 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud