Open prathamesh-gharat opened 1 year ago
The following structure will allow more flexibility.
{protocol}://{hostname}:{port}{/api_prefix}
@prathamesh-gharat the URL is indeed constructed as you have specified. Except for the /api_prefix part. That would be upto developers to add.
Could you please share a screenshot / text guide of how to add the /api_prefix from the WordPress backend screen? or are there any hooks provided by the plugin in WordPress that allows us to do the same?
Hi @prathamesh-gharat
I am not seeing your objective here. Can you please provide and example of what you're trying to do.
Oh sorry, I re-read my first message and it was not clear. I was trying to host typesense in a sub-directory like structure.
For example https://example.com/reverse-proxy/health
but the plugin ends up constructing the URL like following. https://example.com/reverse-proxy/:443/health
which is wrong, it should have been https://example.com:443/reverse-proxy/health
. The important part of the example is 'reverse-proxy' and ':443'
Edit 1: Which is why I suggest providing an additional field / hook for API prefix i.e. something like
/reverse-proxy` in my example.
@prathamesh-gharat This isn't possible right now. On the frontend we use instant search js And the configuration with Typesense Adapter is like the following
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: defaultSettings.search_api_key,// Be sure to use an API key that only allows search operations
nodes: [{
host: defaultSettings.node,
port: defaultSettings.port,
protocol: protocol,
}],
}, cacheSearchResultsForSeconds: 2 * 60, // Cache search results from server. Defaults to 2 minutes. Set to 0 to disable caching.
// The following parameters are directly passed to Typesense search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: searchParams,
})
As such it's not possible to use this with a subdirectory pattern at this moment.
@prathamesh-gharat
After further consideration - this should be doable with some mods. I've attached here a zip for the requested changes - can you please have a look and see if this works for you search-with-typesense.zip
@digamber89 will this make it into a release? Either this or the ability to omit the port altogether. so https://example.com:443/reverse-proxy/health
or https://example.com/reverse-proxy/health
@digamber89 just tried your patch but doesn't quite seem to work as intended, at least for autocomplete (no change to the url there, it doesn't seem to use the new path setting)
I could take a look at this feature if there is any way to contribute?
The URL is constructed like {NODE URI}{PORT} which results in.
https://example.com/reverse-proxy/:443/health