Fix blocked http-request for version number on https site #773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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
.