fix: forward HERMES_API_TOKEN to gateway in proxy routes - #19
Open
coolswood wants to merge 1 commit into
Open
Conversation
Several server-side proxy routes forwarded requests to the gateway without
the Authorization: Bearer header, even when HERMES_API_TOKEN was set. With
API_SERVER_KEY configured the gateway rejects them with 401 gateway_auth_failed,
breaking Jobs ("Failed to load jobs: 401"), the model dropdown, run events
and approvals. The universal proxy also forwarded the browser's headers
verbatim, but the browser authenticates with a hermes-auth cookie, not the
gateway bearer.
Reuses the existing BEARER_TOKEN from gateway-capabilities.ts (same pattern
hermesGet/hermesPost already use) and passes Authorization on every gateway
fetch in the affected routes. The proxy now sets Authorization explicitly
from HERMES_API_TOKEN.
Affected routes:
- src/routes/api/hermes-jobs.ts (GET, POST)
- src/routes/api/hermes-jobs.$jobId.ts (GET, POST, PATCH, DELETE)
- src/routes/api/models.ts (fetchHermesModels)
- src/routes/api/hermes-runs.ts (POST)
- src/routes/api/hermes-runs.$runId.events.ts (SSE GET)
- src/routes/api/approvals.$approvalId.approve.ts (native /approve)
- src/routes/api/approvals.$approvalId.deny.ts (native /deny)
- src/routes/api/hermes-proxy/$.ts (sets Authorization from BEARER_TOKEN)
Closes JPeetz#17
|
@coolswood is attempting to deploy a commit to the Joerg Peetz's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Fixes #17.
Several server-side proxy routes forwarded requests to the Hermes gateway without the
Authorization: Bearerheader, even whenHERMES_API_TOKENwas set. When the gateway hasAPI_SERVER_KEYconfigured (the documented, required setting forAPI_SERVER_HOST=0.0.0.0), it correctly rejects these requests with401 gateway_auth_failed.This breaks the Jobs view (
Failed to load jobs: Failed to fetch jobs: 401), leaves the model dropdown empty, drops run events before they reach the browser, and forces approvals through the chat-command fallback instead of the native endpoint. Gateway logs fill with:A canonical helper already exists —
BEARER_TOKENexported fromsrc/server/gateway-capabilities.ts, already used byhermesGet/hermesPostinsrc/server/hermes-api.ts. The proxy routes just didn't use it.Changes
Reuses the existing
BEARER_TOKENpattern and passesAuthorization: Bearer ...on every gatewayfetchin the affected routes. The universal proxy (hermes-proxy/$.ts) now setsAuthorizationexplicitly fromHERMES_API_TOKENrather than copying the browser request's headers verbatim — the browser authenticates with ahermes-authcookie, which the gateway does not accept as a bearer token.src/routes/api/hermes-jobs.ts(GET, POST)src/routes/api/hermes-jobs.$jobId.ts(GET, POST, PATCH, DELETE)src/routes/api/models.ts(fetchHermesModels)src/routes/api/hermes-runs.ts(POST)src/routes/api/hermes-runs.$runId.events.ts(SSE GET)src/routes/api/approvals.$approvalId.approve.ts(native/approve)src/routes/api/approvals.$approvalId.deny.ts(native/deny)src/routes/api/hermes-proxy/$.ts(setsAuthorizationfromBEARER_TOKEN)Verification
Against Hermes Agent v0.20.0 (
API_SERVER_ENABLED=true,API_SERVER_HOST=0.0.0.0,API_SERVER_KEYset):GET /api/hermes-jobs?include_disabled=trueGET /api/modelsGET /v1/runs/{id}/events401log lines (~8/min)npx tsc --noEmitintroduces no new errors (the 4 pre-existing errors onmainare unrelated: the missingremark-math/rehype-katexdeps and two untouched files).prettier --checkpasses on all changed files.Related: #18 (separate but similar-class bug —
listSessions/getMessagesreading.itemsinstead of.data).