fix(frontend): normalise API URLs built by hand - #292
Open
chattermate wants to merge 1 commit into
Open
Conversation
Eight places built a URL as `${getApiUrl()}/path` for the things that need a
real URL rather than an axios call — OAuth installs, download links, the ticket
webhook URL we show the user. A self-hoster may set API_URL with a trailing
slash, and those then emit `/api/v1//crm/...`. Starlette matches paths exactly,
so it 404s.
Adds apiPath() and routes the hand-built URLs through it. myAvatarUrl already
stripped the trailing slash itself; it now shares the helper.
LoginView's legacy `${getApiUrl()}${redirectPath}` branch is left alone: that
path deliberately has no separator, so normalising it would change behaviour.
Signed-off-by: chattermate <admin@chattermate.chat>
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.
Follow-up to #288.
Eight places built a URL as
${getApiUrl()}/path— the cases that need a real URL string rather than an axios call: OAuth installs (CRM, Slack, Jira, Shopify), the conversation file download link, and the ticket alert webhook URL we show the user. A self-hoster is free to setAPI_URLwith a trailing slash, and those all emit/api/v1//crm/.... Starlette matches paths exactly, so it 404s.Adds
apiPath()inconfig/api.tsand routes them through it.myAvatarUrlalready stripped the trailing slash by hand and now shares the helper.Left alone deliberately: LoginView's legacy
${getApiUrl()}${redirectPath}branch has no separator on purpose, so normalising it would change behaviour rather than fix it.No behaviour change for a normally-configured install — the tests pin the exact URLs. Suite green (371), typecheck and lint clean. (
LoginView.vue:254has a pre-existing unused-var lint error, unrelated and also present on main.)