opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.65k stars 867 forks source link

Add proxy option on Router #854

Open carloseustaquio opened 2 years ago

carloseustaquio commented 2 years ago

Is your feature request related to a problem? Please describe.

I'm working on an OpenSearch Dashboard plugin where I need to handle the front-end requests on a different back-end server. Request: client ==> /server ==> /custom-backend. I was using a BFF approach, redirecting every request manually, but it's been very painful and verbose.

client ==> /server/endpoint-1 ==> /custom-backend/endpoint-1
client ==> /server/endpoint-2 ==> /custom-backend/endpoint-2
client ==> /server/endpoint-3 ==> /custom-backend/endpoint-3

Describe the solution you'd like

Since the hapi.js server has a route proxy option, I'd like to propose exposing this proxy option as a method in the router interface. This way, we only need to set up the proxy endpoint and it will redirect every request to my backend service.

path= "/server"
proxyPath = "/custom-backend"

client ==> +----------------------+ ==> /custom-backend/endpoint-1
client ==> |  Proxy  /server    | ==> /custom-backend/endpoint-2
client ==> +----------------------+ ==> /custom-backend/endpoint-3

Describe alternatives you've considered

I considered turning my custom back-end public and sending the front-end requests directly to it, but, doing so, I would lose the integration with the Dashboard Security plugin that is handling authentication in my application.

Additional context

I forked the OpenSearch and worked out a solution. I'd like to share it with the community, and see if it would be a good feature for other people.

rios0rios0 commented 2 years ago

Many thanks!