-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Using Grafana API in OSJS #9
Comments
Try using a proxy on the server: |
Example:
|
Then, Is it possible to call grafana API directly in widget? |
Not directly, via the OS.js server as a proxy request. |
If you can't control the policies on the grafana server, this is what you need. If you run OS.js on a reverse-proxy server like nginx, you can just set up the proxy there instead. |
I thought, it must be like swiftstack, that writing an adapter was helpful. Here I want to show grafana data on widget as a chart. I need to call method in widget for getting information from grafana. You say if I add grafana as proxy then I can call its api? |
Yes, then you can call the HTTP APIs in your client via your proxy just using an URL likke |
Thanks a lot. |
No problem! Closing the issue, but feel free to keep commenting if you run into something. |
I defined bellow code in servers's config, but I'm not certain how to use it in widget(I tested in widget by fetch, but already i get cors policy error). How must i use api in widget? proxy: [{
source: 'http://zdrive.ir:3000',
destination: 'http://localhost:8000/',
options: {
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
proxyReqOpts.headers = {'Authorization': `Bearer ${token}`};
return proxyReqOpts;
}
}
}] |
You have to define the proxy like in my example:
This allows you just to use |
Oh, shame on me. You are right. first I must define my source path and use it in widget then proxy converts it to destination path. Such a huge mistake :'| |
No worries :) Hopefully this will solve your issue! |
Hi,
I have plan to use grafana api in osjs/widget.
Because of CORS policy I can't use it directly in client side.
What is your suggestion to use grafana api in osjs?
Is it need to use server service provider to handle this kind of problem or should be addressed in other ways?
The text was updated successfully, but these errors were encountered: