I'm looking for a way to make some data (headers received by the Kibana Server) available to the plugin front-end (re-use the headers to fetch some data through an external API).
It is also worth noticing that I retrieve the headers like this :
I've seen that I can use server.injectUiAppVars in the init method of the plugin to inject data and retrieve it in the browser.
I'm having trouble figuring out how to retrieve the headers from the hapi requests life-cycle (via the code above) and inject them with the injectUiAppVars function. Any clues ?
Maybe you can give a bit more details about the problem you're trying to solve? It sounds like you are trying to provide credentials/authentication token to the frontend so that the frontend code can do a fetch request to an external API. Why are you trying read the headers of incoming requests in the hapi requests life-cycle?
If you share variables with the frontend using server.injectUiAppVars you can retrieve these on the browser with
import chrome from 'ui/chrome';
const myVarName = chrome.getInjected('myVarName');
It is indeed what I'm trying to do. We access Kibana through a proxy, and that proxy provides two headers that should be used to grant access to an external API. To be honest, I haven't found a way to grab those headers from Kibana except using hapi life-cycle. Do you know any other way ?
I've been tinkering a bit with the code, and got something that seems to be working fine.
I guess I was having trouble because I was tired of my week .
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.