Code Monkey home page Code Monkey logo

Comments (18)

Nicare avatar Nicare commented on July 4, 2024

Hello,

Same here, I've tried with different GLPi version. Twicking with app token and/or user token : same result.
I've cut and paste the IP address shown in the error message to the API application : same result.

I'm able to manually connect from the Grafana machine (using wget for instance). So I don't thing it could be a IP setup issue.

Any idea ?

Thanks

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

Grafana on same server than GLPI ?

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

In configuration in grafana, you had tried in proxy AND direct or only one of both ?

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

Without CORS configuration, it can't works. So check the CORS config (I added doc for that)

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

Yes in all cases you need have CORS configured

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

Check in 'network' tab of you browser (developper tools) and you can have more information about the error

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

This is what I've found :


2018-06-19_1936
grafana_app.ts:59 warning rootScope onAppEvent called without localscope

:3000/api/datasource…oxy/2/initSession:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
2:1 Failed to load https://192.168.209.139/glpi/apirest.php/initSession: Request header field App-Token is not allowed by Access-Control-Allow-Headers in preflight response.
angular.js:12837 GET http://192.168.209.137:3000/api/datasources/proxy/2/initSession 400 (Bad Request)

Doesn't mean things for me :(

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

App-Token is not allowed by Access-Control-Allow-Headers so not sure the header you have put in apache configuration is in the right place

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

Oups, missing a refresh, my mistake, this error was with browser mode (which is not my target).

If I do a connection with server mode I only have this error :
GET http://192.168.209.137:3000/api/datasources/proxy/2/initSession 400 (Bad Request)

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

I think it's the same problem

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

Grrr , it wasn't the correct file :(

Modifying the correct one fixed "Request header field App-Token" in browser mode.
It works in browser mode 👍

192.168.209.1 - - [19/Jun/2018:21:14:52 +0200] "OPTIONS /glpi/apirest.php/initSession HTTP/1.1" 200 -
192.168.209.1 - - [19/Jun/2018:21:14:52 +0200] "GET /glpi/apirest.php/initSession HTTP/1.1" 200 46

But on server mode is still stuck with error 400 :
192.168.209.140 - - [19/Jun/2018:21:14:24 +0200] "GET /glpi/apirest.php/initSession HTTP/1.1" 400 140

Do you think it could be worth to stop doing SSL and sniff the packets to see what's going on ?

Many thanks for your help

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

In server, there is a problem with code in API, you need modify the code in GLPI like in this comment: #10 (comment)

from glpi_app_grafana.

Nicare avatar Nicare commented on July 4, 2024

Perfect, it works with server option too 👍 👍 👍

My version was not the same, but the 3 lines solved the issue :
// retrieve ip of client
$this->iptxt = (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"]
: $SERVER["REMOTE_ADDR"]);
$spl = explode(',', $this->iptxt);
if (count($spl) > 1) {
$this->iptxt = $spl[0];
}
$this->ipnum = (strstr($this->iptxt, ':')===false ? ip2long($this->iptxt) : '');

Great, Thanks,
Need to play with the query now :)

from glpi_app_grafana.

ddurieux avatar ddurieux commented on July 4, 2024

Nice ;)

from glpi_app_grafana.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.