Skip to content

feat(headless): accept a per-request navigator context in SSR search - #8704

Merged
y-lakhdar merged 1 commit into
mainfrom
kit-6374-ssr-search-per-request-navigator-context
Oct 19, 2026
Merged

y-lakhdar merged 1 commit into
mainfrom
kit-6374-ssr-search-per-request-navigator-context

Conversation

@y-lakhdar

@y-lakhdar y-lakhdar commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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
    end
Loading

fetchStaticState(), hydrateStaticState() and build() in @coveo/headless/ssr now take an optional navigatorContext, which applies only to that call's engine, as #8495 did for /ssr-commerce. It takes priority over a provider set through extend. The "Missing navigator context" warning and the setNavigatorContextProvider() deprecation notice now name it first.

Evidence

  • Six new tests in search-engine.ssr.test.ts fail without the change and pass with it. They cover the per-request header, no leak into later requests, concurrent requests, priority over extend, no false warning, and hydration:
    await Promise.all([
      fetchStaticState({navigatorContext: {forwardedFor: '5.5.5.5'}}),
      fetchStaticState({navigatorContext: {forwardedFor: '6.6.6.6'}}),
    ])
    x-forwarded-for sent: 5.5.5.5 and 6.6.6.6
    
  • All 303 tests in packages/headless/src/ssr pass locally.

@y-lakhdar
y-lakhdar deployed to pr-workflows October 16, 2026 13:31 — with GitHub Actions Active
@changeset-bot

changeset-bot Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f14349c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@coveo/headless Minor
@coveo/quantic Patch
@coveo/headless-react Patch
@coveo/atomic-hosted-page Patch
@coveo/atomic Patch
@coveo/atomic-legacy Patch
@coveo/shopify Patch
@coveo/ui-kit-sample-atomic-commerce-hybrid Patch
@coveo/ui-kit-sample-atomic-commerce-react Patch
@coveo/ui-kit-sample-atomic-commerce-vite Patch
@coveo/ui-kit-sample-atomic-search-react Patch
@coveo/ui-kit-sample-atomic-search-vite Patch
@coveo/ui-kit-sample-headless-commerce-react Minor
@coveo/ui-kit-sample-headless-commerce-vite Minor
@coveo/ui-kit-sample-headless-search-react Minor
@coveo/ui-kit-sample-headless-search-vite Minor
@coveo/ui-kit-sample-headless-ssr-commerce-express Minor
@coveo/ui-kit-sample-headless-ssr-commerce-nextjs Patch
@coveo/atomic-react Patch
@coveo/atomic-angular Patch

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

@svcsnykcoveo

svcsnykcoveo commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@chromatic-com

chromatic-com Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 439 tests unchanged
🟢 UI Review: No changes
Storybook icon Storybook Publish: 471 stories published

@pkg-pr-new

pkg-pr-new Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
@coveo/atomic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic@8704

@coveo/atomic-hosted-page

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-hosted-page@8704

@coveo/atomic-legacy

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-legacy@8704

@coveo/atomic-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-react@8704

@coveo/bueno

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/bueno@8704

coveo.analytics

npm i https://pkg.pr.new/coveo/ui-kit/coveo.analytics@8704

@coveo/create-atomic-rollup-plugin

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-rollup-plugin@8704

@coveo/headless

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless@8704

@coveo/headless-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless-react@8704

@coveo/quantic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/quantic@8704

@coveo/relay

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/relay@8704

@coveo/shopify

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/shopify@8704

@coveo/atomic-angular

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-angular@8704

commit: f14349c

@y-lakhdar
y-lakhdar marked this pull request as ready for review October 16, 2026 13:38
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Scratch Orgs ready to test this PR:

@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 13:44 — with GitHub Actions Active
@y-lakhdar
y-lakhdar force-pushed the kit-6374-ssr-search-per-request-navigator-context branch from 334081f to c674cae Compare October 16, 2026 14:57
@y-lakhdar
y-lakhdar deployed to pr-workflows October 16, 2026 14:57 — with GitHub Actions Active
@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 14:58 — with GitHub Actions Active
@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 15:01 — with GitHub Actions Active
@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 15:10 — with GitHub Actions Active
Base automatically changed from kit-6365-ssr-search-forwarded-for to main October 16, 2026 15:51
@y-lakhdar
y-lakhdar enabled auto-merge October 16, 2026 17:19
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>
@y-lakhdar
y-lakhdar force-pushed the kit-6374-ssr-search-per-request-navigator-context branch from c674cae to f14349c Compare October 16, 2026 17:21
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:21
@y-lakhdar
y-lakhdar deployed to pr-workflows October 16, 2026 17:21 — with GitHub Actions Active
@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 17:21 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 navigatorContext to 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.

@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 17:25 — with GitHub Actions Active
@y-lakhdar
y-lakhdar deployed to PR Artifacts October 16, 2026 17:34 — with GitHub Actions Active
@y-lakhdar
y-lakhdar added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit a873e42 Oct 19, 2026
98 checks passed
@y-lakhdar
y-lakhdar deleted the kit-6374-ssr-search-per-request-navigator-context branch October 19, 2026 14:02

This branch was successfully deployed

2 active deployments
PR Artifacts — f14349ca Deployed Oct 16, 2026 by y-lakhdar via Run Quantic E2E tests / Merge Playwright reports #20108
pr-workflows — f14349ca Deployed Oct 16, 2026 by y-lakhdar via label #9742
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants