ddurieux / glpi_app_grafana

GNU Affero General Public License v3.0
23 stars 13 forks source link

GLPI 9.4.3 and app for Grafana 1.3.0 #53

Open menemat opened 5 years ago

menemat commented 5 years ago

Hi folks,

I have tried to enable cors on a apache without success. I tried in .htaccess, in glpi.conf or 000-default.conf.

Wich is the correct marker to incapsulate

Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" Header set Access-Control-Allow-Credentials true Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, App-Token, Session-Token"

and in wich file?

I got this:

Access to XMLHttpRequest at 'https://glpi###############initSession' (redirected from 'http://#####/api/datasources/proxy/6/initSession') from origin 'http://#######' has been blocked by CORS policy: Request header field x-ds-authorization is not allowed by Access-Control-Allow-Headers in preflight response.

ddurieux commented 5 years ago

You put this lines into or into ?

menemat commented 5 years ago

I tried: <Directory /var/www> Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" Header set Access-Control-Allow-Credentials true Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, App-Token, Session-Token"

but I got always the same error

menemat commented 5 years ago

/etc/apache2/sites-enabled/glpi.conf

<VirtualHost :80> ...... <Directory /var/www/glpi> Options FollowSymLinks AllowOverride All Order allow,deny allow from all Header set Access-Control-Allow-Origin "" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" Header set Access-Control-Allow-Credentials true Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token,$ ....

a2enmod headers -> Module headers already enabled systemctl restart apache2

glpiAPI glpigrafana glpi-TOKENgrafana glpi-TOKENuser

ddurieux commented 5 years ago

On grafana when you test, check the developper console (F12) to see the real error on HTTP requests

menemat commented 5 years ago

Thanks for the fast answer!

glpi-CORSerror

ddurieux commented 5 years ago

Ok so it's confirmed, it's CORS problem. The error say you use https (443) but in your apache config you have so I think you don't have put the CORS configuration in the right VirtualHost/Directory

menemat commented 5 years ago

Thanks. I put it in glpi.conf as written above. glpi.conf is correctly linked from /sites-available Syntax is OK

Could be a problem due by 3000 port? There are differents apache config file to setup for https unlike http?

ddurieux commented 5 years ago

I don't know, depend of the package of Apache2