Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration should allow hosting typesense being a reverse proxy #6

Open
prathamesh-gharat opened this issue Mar 30, 2023 · 9 comments

Comments

@prathamesh-gharat
Copy link

The URL is constructed like {NODE URI}{PORT} which results in.
https://example.com/reverse-proxy/:443/health

@prathamesh-gharat
Copy link
Author

The following structure will allow more flexibility.
{protocol}://{hostname}:{port}{/api_prefix}

@digamber89
Copy link
Contributor

@prathamesh-gharat the URL is indeed constructed as you have specified.
Except for the /api_prefix part. That would be upto developers to add.

@prathamesh-gharat
Copy link
Author

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?

@digamber89
Copy link
Contributor

Hi @prathamesh-gharat

I am not seeing your objective here.
Can you please provide and example of what you're trying to do.

@prathamesh-gharat
Copy link
Author

prathamesh-gharat commented May 29, 2023

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.

@digamber89
Copy link
Contributor

@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.

@digamber89
Copy link
Contributor

@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

@moussaclarke
Copy link

@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

@moussaclarke
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants