Skip to content

Vanguard: Accept the API address without /api/v2 - #5

Merged
zpl-zak merged 1 commit into
mainfrom
vanguard/api-host-url
Oct 30, 2026
Merged

zpl-zak merged 1 commit into
mainfrom
vanguard/api-host-url

Conversation

@zpl-zak

@zpl-zak zpl-zak commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Summary

The CLI only worked when NEXRENDER_API_URL, --server or a profile's server spelled out the /api/v2 base. People naturally give the API's address (https://api.nexrender.com). The generated client then sent every request to /jobs, /templates and so on at the root and got 404 Not Found. nexrender auth status reported that 404 as a credential that was not accepted, which sends people looking at their token instead of the URL.

config.NormalizeServer, which every server source already goes through, now adds the base:

Server given Before After
https://api.nexrender.com 404 on every call https://api.nexrender.com/api/v2
https://staging.api.nexrender.com/ 404 …/api/v2
https://staging.api.nexrender.com/api 404 …/api/v2
https://staging.api.nexrender.com/api/v2 works unchanged
https://gateway.example.test/nexrender/v2 works unchanged (other paths are kept)

The v3 client still derives its root by dropping /v2, so template commands keep working. The invalid-URL hint now asks for the API address instead of a full /api/v2 URL.

This repository only has main, so the PR targets it.

Found by Vanguard, the new end-to-end suite: its staging run failed preflight with the API address alone.

Testing

  • New TestNormalizeServerDerivesTheAPIBase covers a bare host, a trailing slash, /api, an explicit /api/v2, a local port, a custom gateway path, empty input and a non-URL.
  • gofmt -l (clean), go vet ./..., go test ./....
  • Against staging with NEXRENDER_API_URL=https://staging.api.nexrender.com: auth status resolves the server to …/api/v2 and authenticates, and template list (v3) returns the team's templates.

NEXRENDER_API_URL, --server and profile servers had to spell out the
/api/v2 base. Given only the API's address (https://api.nexrender.com,
as people naturally write it), every request went to /jobs, /templates
and so on at the root and failed with "Not Found", which auth status
reported as a rejected credential.

A server that is just the address, or ends in /api, now gets /api/v2.
Any other path is kept, so gateways that mount the API elsewhere still
work, and URLs that already end in /api/v2 are unchanged.

Found by Vanguard.
@zpl-zak
zpl-zak merged commit d98f9a6 into main Oct 30, 2026
2 checks passed
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