Uh oh!
There was an error while loading. Please reload this page.
feat(data): thread the host's authenticated fetch into provider:'api' data sources (#2725) - #2732
Merged
Merged
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
… data sources (#2725) provider:'api' view data sources used a bare globalThis.fetch, so custom endpoints carried only same-origin cookies while native requests carried Authorization: Bearer — cookie HMAC rotation (dev restart, prod expiry) 401'd those views while the rest of the app kept working. - react: SchemaRendererProvider gains optional apiFetch (inherited by nested providers); useViewData defaults the api adapter's fetch to it. - auth: createAuthenticatedFetch({ sameOriginOnly }) passes cross-origin URLs through untouched so metadata-supplied third-party URLs never see the platform token. - app-shell: console wires a settle-signal-wrapped, same-origin-only authenticated fetch as apiFetch on the root provider. - plugin-gantt: ObjectGantt resolves its api-provider DataSource with the context apiFetch (reads and write-backs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Fixes#2725
Problem
provider: 'api'view data sources went through a bareglobalThis.fetch, so custom endpoints (gantt composite trees, report aggregates) carried only same-origin cookies while every native/api/v1/*request carriedAuthorization: Bearer. The moment cookie HMAC verification failed (dev restart rotating the fallback auth secret, cookie expiry/rotation in prod), those views 401'd while the rest of the app kept working.The injection points existed from day one (
ApiDataSourceacceptsfetch/defaultHeaders,resolveDataSourcepasses them through) but no caller ever wired them — see the root-cause confirmation on the issue.Changes
@object-ui/react—SchemaRendererProvideraccepts an optionalapiFetch; nested providers inherit it from their parent, so re-wrapped subtrees (react pages, studio preview surfaces) keep the host's authentication.useViewDatadefaults the api-provider adapter's fetch to the contextapiFetch(explicitadapterOptions.fetchstill wins).@object-ui/auth—createAuthenticatedFetchgains asameOriginOnlyoption: cross-origin URLs pass through to the bare fetch with noAuthorization/X-Tenant-ID/Accept-Language, so metadata-supplied third-party URLs never see the platform token.@object-ui/app-shell— the console wireswithSettleSignal(createAuthenticatedFetch({ sameOriginOnly: true }))asapiFetchon the rootSchemaRendererProvider, so api-provider requests carry the same credentials as the native adapter channel and stay visible to the ADR-0054 C5 idle probe.@object-ui/plugin-gantt—ObjectGanttresolves its api-provider DataSource with the contextapiFetch, covering reads AND write-backs.Backward compatible: hosts that don't provide
apiFetchkeep the current behaviour (bare fetch + cookies).Tests
auth:sameOriginOnlyattaches on same-origin, strips all credential headers cross-origin, legacy no-option behaviour unchanged (3 new).react:useViewDataroutes api-provider requests through the contextapiFetch/ explicit override wins (2 new); provider nesting inheritance (3 new).plugin-gantt:ObjectGanttreads throughSchemaRendererContext.apiFetchinstead of the bare global fetch, and still falls back without one (2 new).turbo run build --filter=@object-ui/app-shell(29 packages) passes.Docs updated (
react/authREADMEs,plugin-gantt.mdx) + changeset.🤖 Generated with Claude Code