feat: add search redirect endpoint#7055
Conversation
| }); | ||
| } | ||
|
|
||
| async searchRedirect( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
probably in samples/headless/commerce-react
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
| export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client.js'; | ||
| export { | ||
| getCommerceApiBaseUrl, | ||
| getCommerceRedirectApiBaseUrl, |
There was a problem hiding this comment.
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
| function extractEnvironmentFromUrl(url: string): PlatformEnvironment { | ||
| return url.includes('dev') ? 'dev' : 'prod'; | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.

✅ Checklist
.mdxfileindex.tsandlazy-index.tsfiles.COMHUB2-1211