Skip to content

fix(frontend): normalise API URLs built by hand - #292

Open
chattermate wants to merge 1 commit into
mainfrom
fix/api-url-trailing-slash
Open

fix(frontend): normalise API URLs built by hand#292
chattermate wants to merge 1 commit into
mainfrom
fix/api-url-trailing-slash

Conversation

@chattermate

Copy link
Copy Markdown
Owner

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 set API_URL with a trailing slash, and those all emit /api/v1//crm/.... Starlette matches paths exactly, so it 404s.

Adds apiPath() in config/api.ts and routes them through it. myAvatarUrl already 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:254 has a pre-existing unused-var lint error, unrelated and also present on main.)

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>
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