Send bearer token on raw fetch calls to rag-analytics - #191
Open
collinschreyer-dev wants to merge 1 commit into
Open
Send bearer token on raw fetch calls to rag-analytics#191collinschreyer-dev wants to merge 1 commit into
collinschreyer-dev wants to merge 1 commit into
Conversation
Companion to the srt-api change that adds token() and admin_only() to the rag-analytics routes. Without this, those calls would start returning 401. Angular attaches the bearer token through TokenInterceptor, which only sees HttpClient traffic. Sixteen calls in the analytics and home components used raw fetch() instead, which bypasses the interceptor and sent no Authorization header. That is why those endpoints had no server-side guard: adding one would have broken them. art-lookup, the single guarded route, was also the single one called through HttpClient. Adds authHeaders() in shared/services and applies it at each fetch call site. home.component already did this by hand for its streaming analyze call, so this generalizes an existing local fix rather than introducing a new pattern. The execute-pipeline upload deliberately gets no Content-Type, so the browser can set the multipart boundary for its FormData body. No request logic changed beyond the added header. Verified with a production build and a typecheck of the touched files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
Companion to GSA/srt-api#208, which adds
token()/admin_only()to the rag-analytics routes. These must merge together — without this change those calls start returning 401.Why the header was missing
Angular attaches the bearer token via
TokenInterceptor, which only seesHttpClienttraffic. Sixteen calls in the analytics and home components used rawfetch(), which bypasses the interceptor entirely and sent noAuthorizationheader.That is precisely why the server routes had no guard: adding one would have broken them.
art-lookupwas the one route called throughHttpClientand the one route with a server-side guard.Change
Adds
authHeaders()insrc/app/shared/services/auth-fetch.tsand applies it at eachfetch()call site.home.component.tsalready did this by hand for its streaming analyze call, so this generalizes an existing local fix rather than inventing a pattern.ai-playground.component.tshome.component.tsai-analytics.component.tsai-pipeline.component.tsThe
execute-pipelineupload deliberately gets noContent-Type, so the browser sets the multipart boundary for itsFormDatabody.Verification
fetch()calls to rag-analytics now carry auth; audited individually.ng build --configuration=dev) succeeds; only pre-existing SASS and quill warnings.tsc --noEmitreports no errors in the touched files. Remaining repo-wide errors are pre-existing missing@types/jestin spec/e2e files.🤖 Generated with Claude Code