Resolve client API paths relative to the base URL - #337
Open
ThoughtzThruKeyz wants to merge 1 commit into
Open
ThoughtzThruKeyz wants to merge 1 commit into
ThoughtzThruKeyz wants to merge 1 commit into
Conversation
Every call in komf-client used an absolute path such as "/api/config".
Ktor's defaultRequest resolves an absolute path against the host root,
so when Komf is served under a subpath behind a reverse proxy, the
subpath in the configured base URL is silently dropped:
base URL https://host/komf -> GET https://host/api/config
Use relative paths ("api/config") so requests resolve against the base
URL, and normalize the base URL to end in exactly one "/". The
normalization is needed too: without a trailing slash, relative
resolution replaces the last path segment, so "https://host/komf" would
still lose "komf".
Checked against a MockEngine for base URLs "https://host",
"https://host/komf" and "https://host/komf/": the latter two now request
https://host/komf/api/..., and the plain host produces the same URLs as
before, so setups without a subpath are unaffected.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ThoughtzThruKeyz
marked this pull request as ready for review
September 17, 2026 22:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When Komf is served under a subpath behind a reverse proxy (e.g.
https://host/komf),komf-clientdrops the subpath from every request, so Komelia and the browser extension can't reach it.Every client call used an absolute path like
"/api/config", and Ktor'sdefaultRequestresolves an absolute path against the host root. This switches them to relative paths ("api/config") and normalizes the base URL to end in a single/. The normalization matters too: without a trailing slash, relative resolution replaces the last segment, sohttps://host/komfwould still losekomf.Requested URLs, recorded with a
MockEngine:https://hosthttps://host/api/confighttps://host/api/confighttps://host/komfhttps://host/api/confighttps://host/komf/api/confighttps://host/komf/https://host/api/confighttps://host/komf/api/configThe same holds for the metadata, notification and job calls, and for the new
updateBookWalkerDb. Setups without a subpath get identical URLs.Only path strings in
komf-clientchange; no API or server changes.🤖 Generated with Claude Code