docs(troubleshooting): list the headers a custom CORS allow-list must include - #24
docs(troubleshooting): list the headers a custom CORS allow-list must include#24PMerlet wants to merge 2 commits into
Conversation
… include Agents announcing the canUseProjectionViaHeader capability receive the get-one projection in a Forest-Projection request header; a host app answering the preflight with an explicit allowedHeaders list must include it or the record details view breaks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
| **Check:** | ||
|
|
||
| - The Forest agent is mounted **before** any other middleware. In NestJS specifically, the Nest App Factory's CORS configuration can interfere with `@forestadmin/agent`. Configure it after mounting the agent. | ||
| - If your application's own CORS middleware answers the preflight requests with an explicit header allow-list (`allowedHeaders`), include every header the Forest UI sends: `Authorization`, `Content-Type`, `Forest-Context-Url`, and `Forest-Projection`. A missing entry blocks the preflight of the requests that carry it — a missing `Forest-Projection` breaks the record details view. |
There was a problem hiding this comment.
Claude Fable 5 (claude-fable-5): Should fix
"A missing entry blocks the preflight" is mechanically backwards, and on this page that matters: the OPTIONS request itself succeeds (204 from express cors and @koa/cors alike) — the browser then rejects the preflight response and cancels the actual request, which is never sent.
Line 8 of this page tells the reader to open the Network tab to diagnose. Told that the preflight is "blocked", they'll scan for a failing OPTIONS row, see 204 on every one, and rule the allow-list out — the exact misdiagnosis this bullet exists to prevent. The real signal is the cancelled GET and the console error Request header field forest-projection is not allowed by Access-Control-Allow-Headers in preflight response.
Suggested rewording: "…the browser rejects the preflight response and cancels the request (the OPTIONS row still shows 204 — look for the console error naming the header)." Naming the console string also gives readers something to search for.
There was a problem hiding this comment.
Right — the misdiagnosis path you describe is exactly what the page's own "open the Network tab" advice would trigger. Fixed in 27e02d4: the bullet now states that the OPTIONS request still returns 204, that the browser rejects the preflight response and cancels the actual request, and it quotes the console error verbatim so readers have a string to search for.
| **Check:** | ||
|
|
||
| - The Forest agent is mounted **before** any other middleware. In NestJS specifically, the Nest App Factory's CORS configuration can interfere with `@forestadmin/agent`. Configure it after mounting the agent. | ||
| - If your application's own CORS middleware answers the preflight requests with an explicit header allow-list (`allowedHeaders`), include every header the Forest UI sends: `Authorization`, `Content-Type`, `Forest-Context-Url`, and `Forest-Projection`. A missing entry blocks the preflight of the requests that carry it — a missing `Forest-Projection` breaks the record details view. |
There was a problem hiding this comment.
Claude Fable 5 (claude-fable-5): Should fix
"a missing Forest-Projection breaks the record details view" is stated as current behaviour, but it only becomes true once agent-nodejs#1813 and forestadmin#9893 ship and the agent announces canUseProjectionViaHeader — on every released agent today the header is never sent, so its absence breaks nothing.
Consequence: a reader whose details view is broken right now adds Forest-Projection, observes zero change, and the page loses credibility on the other three headers — which are correct today.
Zero-cost fix that also encodes the merge-order dependency: "…a missing Forest-Projection breaks the record details view on agents that announce the canUseProjectionViaHeader capability." And this PR shouldn't merge ahead of the two code PRs.
There was a problem hiding this comment.
Fixed in 27e02d4: the impact is now scoped to "agents that announce the canUseProjectionViaHeader capability". The merge-order dependency is also recorded in the PR body — this PR must not merge before ForestAdmin/agent-nodejs#1813 and ForestAdmin/forestadmin#9893.
| **Check:** | ||
|
|
||
| - The Forest agent is mounted **before** any other middleware. In NestJS specifically, the Nest App Factory's CORS configuration can interfere with `@forestadmin/agent`. Configure it after mounting the agent. | ||
| - If your application's own CORS middleware answers the preflight requests with an explicit header allow-list (`allowedHeaders`), include every header the Forest UI sends: `Authorization`, `Content-Type`, `Forest-Context-Url`, and `Forest-Projection`. A missing entry blocks the preflight of the requests that carry it — a missing `Forest-Projection` breaks the record details view. |
There was a problem hiding this comment.
Claude Fable 5 (claude-fable-5): Preferential
Two wording points on the same sentence:
-
"every header the Forest UI sends" is a closed-set claim the UI doesn't honor: it also sends
Accept: application/jsonon every agent request (basic-adapter.js/authenticated-server-fetch.ts— CORS-safelisted, so the four listed headers remain the correctallowedHeadersvalue), and smart views / custom action code can pass arbitrary extra headers throughlianaServerFetch. "every header the Forest UI sends that requires allow-listing" keeps the instruction exact without the false promise. -
This bullet only applies when the reader has not followed the bullet directly above it (agent mounted first →
@koa/corsreflectsAccess-Control-Request-Headersand the host allow-list is never consulted). Sequenced as sibling checks, a reader who mounted the agent first can still add four headers and observe nothing. Opening with the fallback framing — "If you cannot mount the agent first and your own CORS middleware answers the preflight…" — plus the tell (a fixedAccess-Control-Allow-Headerslist in the OPTIONS response means your middleware answered; an echo of what was requested means the agent did) lets readers know which case they're in.
There was a problem hiding this comment.
Both taken in 27e02d4: the bullet opens with the fallback framing ("If you cannot mount the agent first and your own CORS middleware answers the preflight requests…"), the list is qualified as "every header the Forest UI sends that requires allow-listing", and it closes with the tell — a fixed Access-Control-Allow-Headers list comes from the host middleware, an echo of the requested headers comes from the agent.
- The OPTIONS request returns 204 even when a header is missing from the allow-list: the browser rejects the preflight response and cancels the actual request. Point the reader at the console error instead of a failing OPTIONS row. - Scope the Forest-Projection impact to agents announcing the canUseProjectionViaHeader capability. - Frame the check as the fallback to mounting the agent first, and explain how to tell which middleware answered the preflight. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Related to PRD-892 (
Forest-Projectionheader for get-one projections).When a host application answers the CORS preflight itself with an explicit
allowedHeaderslist, the newForest-Projectionheader must be included or the record details view breaks once the agent announces thecanUseProjectionViaHeadercapability. This documents the full list of headers such an allow-list must contain, in the CORS section of the troubleshooting guide.Agent PR: ForestAdmin/agent-nodejs#1813 · Front PR: ForestAdmin/forestadmin#9893
🤖 Generated with Claude Code
Note
Document required headers for custom CORS
allowedHeaderslists in troubleshooting guideAdds a bullet to the CORS section of troubleshooting.mdx specifying that a custom
allowedHeaderslist must includeAuthorization,Content-Type,Forest-Context-Url, andForest-Projection. OmittingForest-Projectionbreaks the record details view; omitting the others blocks preflight requests entirely.Changes since #24 opened
Macroscope summarized b15eae2.
Important
Merge order: do not merge before ForestAdmin/agent-nodejs#1813 and ForestAdmin/forestadmin#9893 — the
Forest-Projectionguidance only becomes true once agents announce thecanUseProjectionViaHeadercapability.