Skip to content

feat: add search redirect endpoint#7055

Closed
vdunlop-coveo wants to merge 8 commits intomainfrom
feat/COMHUB2-1211-redirects
Closed

feat: add search redirect endpoint#7055
vdunlop-coveo wants to merge 8 commits intomainfrom
feat/COMHUB2-1211-redirects

Conversation

@vdunlop-coveo
Copy link
Copy Markdown
Contributor

@vdunlop-coveo vdunlop-coveo commented Feb 3, 2026

✅ Checklist

  • 🧪 The component is unit tested
  • 🧪 The component includes E2E tests
  • 🗑️ Old Cypress tests exclusive to the component are removed
  • 📖 The component is documented in storybook with an .mdx file
  • ♿ The component complies with the Web Content Accessibility Guidelines.
  • 🌐 All strings intended for humans or assistive technology must be localized with i18n.
  • 📦 The Lit component is exported in the appropriate index.ts and lazy-index.ts files.
  • 🎨 CSS parts are documented still accessible.
  • 🦥 Slotted Content, public methods and properties are documented
  • 🔄 The component outputs the same Angular output as before with Stencil
  • 🏷️ The component declares the component type in the HTMLElementTagNameMap

COMHUB2-1211

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 3, 2026

🔗 Scratch Orgs ready to test this PR:

Comment thread packages/headless/src/api/commerce/common/request.ts Outdated
});
}

async searchRedirect(
Copy link
Copy Markdown
Contributor

@Tooni Tooni Feb 3, 2026

Choose a reason for hiding this comment

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

question: i'm a bit confused about how this would be used by a client. Does the sample code have redirects stuff? If not, could you try adding it?

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.

probably in samples/headless/commerce-react

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've wired the endpoint, I'd missed that part. Could you check if it makes sense now? Do I still need to add a sample?

Copy link
Copy Markdown
Contributor

@Tooni Tooni Feb 5, 2026

Choose a reason for hiding this comment

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

i dont think the commerce-api-client is accessible to developers trying to use Headless, so this still doesn't make sense imo.

I think we should be updating the headless-search-box controller, in performSearch. So, when a search is made, the controller checks if a redirect should happen (by calling the API client) before it makes its search query. You may also need to update the headless-search controller

EDIT: oh maybe you just need to ensure the Standalone Search Box is using the redirect URL properly? Not sure what the difference between it and the regular one are. I guess the regular one doesnt need redirects cos it will be trying to show query suggestions anyway

the search box is already used by samples, so I imagine you would be able to set up a redirect on the test org (searchuisamples in prod) and try it out there

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.

i only read this code for the first time last week though. i think we should talk to someone who wrote it. Did you talk to @fbeaudoincoveo?

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.

or perhaps @Spuffynism?

export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client.js';
export {
getCommerceApiBaseUrl,
getCommerceRedirectApiBaseUrl,
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.

suggestion: i dont think we should expose this until a need for it is expressed

my understanding of Headless is that we should expect that they use the endpoint by creating a controller, which internally calls the API client, which uses the URL

Comment on lines +245 to +247
function extractEnvironmentFromUrl(url: string): PlatformEnvironment {
return url.includes('dev') ? 'dev' : 'prod';
}
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.

suggestion: i doubt you need to do this. None of the other calls to APIs do and i dont see why this should be different.

i believe the environment is already in the URL in the request, from the engine-configuration

Copy link
Copy Markdown
Contributor

@Tooni Tooni Feb 5, 2026

Choose a reason for hiding this comment

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

they set up a configuration, including an env, when they call buildCommerceEngine https://github.com/coveo/ui-kit/blob/main/packages/headless/src/app/commerce-engine/commerce-engine.ts

Copy link
Copy Markdown
Contributor

@Tooni Tooni Feb 5, 2026

Choose a reason for hiding this comment

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

e.g. in the barca sports repo

image

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.

and then this config is eventually passed down through to the api client through one of the actions files like search-actions, when it creates a request. It's quite indirect and hard to follow though.

You could likely test it with the commerce-react headless sample by setting the environment variable when the engine is configured.

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.

2 participants