Repository navigation
feat(headless): accept a per-request navigator context in SSR search - #8704
Conversation
🦋 Changeset detectedLatest commit: f14349c The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Tip All tests passed and all changes approved!🟢 UI Tests: 439 tests unchanged |
@coveo/atomic
@coveo/atomic-hosted-page
@coveo/atomic-legacy
@coveo/atomic-react
@coveo/bueno
coveo.analytics
@coveo/create-atomic-rollup-plugin
@coveo/headless
@coveo/headless-react
@coveo/quantic
@coveo/relay
@coveo/shopify
@coveo/atomic-angular
commit: |
334081f to
c674cae
Compare
fetchStaticState(), hydrateStaticState() and build() in @coveo/headless/ssr now take an optional navigatorContext. It applies to that call's engine only, including its x-forwarded-for header, without mutating the shared definition, so concurrent requests can't read each other's context. It wins over a provider set through extend, the same way /ssr-commerce does it. The missing navigator context warning and the setNavigatorContextProvider deprecation notice now name it first, next to a navigatorContextProvider on defineSearchEngine(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c674cae to
f14349c
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation preserves fallback behavior and includes regression coverage, with no unresolved findings.
0 open findings
What changed in this PR
Adds per-request navigator context to Headless SSR search, matching SSR commerce while avoiding shared-definition mutation.
Changes:
- Adds optional
navigatorContextto build, static-state fetching, and hydration. - Preserves provider fallback and gives per-request context precedence over
extend. - Adds six regression tests and updates migration guidance.
| File | Description |
|---|---|
| packages/headless/src/ssr/search/engine/search-engine.ssr.ts | Applies request-local context and updates warnings. |
| packages/headless/src/ssr/search/engine/search-engine.ssr.test.ts | Tests isolation, precedence, warnings, and hydration. |
| packages/headless/src/ssr/common/types/hydrate-static-state.ts | Adds hydration context, excluding fromBuildResult. |
| packages/headless/src/ssr/common/types/fetch-static-state.ts | Adds request context, excluding fromBuildResult. |
| packages/headless/src/ssr/common/types/engine.ts | Updates deprecated setter guidance. |
| packages/headless/src/ssr/common/types/build.ts | Adds the build context option. |
| .changeset/headless-ssr-search-per-request-navigator-context.md | Records the minor release addition. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
KIT-6374
Summary
sequenceDiagram participant A as Request A participant B as Request B participant Def as Shared engine definition participant API as Search API alt setNavigatorContextProvider() A->>Def: setNavigatorContextProvider(A) Note over A: awaits something B->>Def: setNavigatorContextProvider(B) A->>Def: fetchStaticState() Def->>API: request A, with B's x-forwarded-for else navigatorContext (this PR) A->>Def: fetchStaticState({navigatorContext: A}) B->>Def: fetchStaticState({navigatorContext: B}) Def->>API: each request with its own x-forwarded-for endfetchStaticState(),hydrateStaticState()andbuild()in@coveo/headless/ssrnow take an optionalnavigatorContext, which applies only to that call's engine, as #8495 did for/ssr-commerce. It takes priority over a provider set throughextend. The "Missing navigator context" warning and thesetNavigatorContextProvider()deprecation notice now name it first.Evidence
search-engine.ssr.test.tsfail without the change and pass with it. They cover the per-request header, no leak into later requests, concurrent requests, priority overextend, no false warning, and hydration:packages/headless/src/ssrpass locally.