Skip to content

Resolve client API paths relative to the base URL - #337

Open
ThoughtzThruKeyz wants to merge 1 commit into
Snd-R:masterfrom
ThoughtzThruKeyz:pr/relative-client-paths
Open

ThoughtzThruKeyz wants to merge 1 commit into
Snd-R:masterfrom
ThoughtzThruKeyz:pr/relative-client-paths

Conversation

@ThoughtzThruKeyz

@ThoughtzThruKeyz ThoughtzThruKeyz commented Sep 17, 2026

Copy link
Copy Markdown

When Komf is served under a subpath behind a reverse proxy (e.g. https://host/komf), komf-client drops 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's defaultRequest resolves 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, so https://host/komf would still lose komf.

Requested URLs, recorded with a MockEngine:

base URL before after
https://host https://host/api/config https://host/api/config
https://host/komf https://host/api/config https://host/komf/api/config
https://host/komf/ https://host/api/config https://host/komf/api/config

The 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-client change; no API or server changes.

🤖 Generated with Claude Code

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
ThoughtzThruKeyz marked this pull request as ready for review September 17, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant