glpi_app_grafana icon indicating copy to clipboard operation
glpi_app_grafana copied to clipboard

GLPI 9.4.3 and app for Grafana 1.3.0

Open menemat opened this issue 6 years ago • 8 comments

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.

menemat avatar Nov 22 '19 17:11 menemat

You put this lines into <VirtualHost> or into <Directory> ?

ddurieux avatar Nov 23 '19 06:11 ddurieux

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" </Directory>

but I got always the same error

menemat avatar Nov 25 '19 07:11 menemat

/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,$ </Directory> .... </VirtualHost>

a2enmod headers -> Module headers already enabled systemctl restart apache2

glpiAPI glpigrafana glpi-TOKENgrafana glpi-TOKENuser

menemat avatar Nov 26 '19 08:11 menemat

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

ddurieux avatar Nov 26 '19 08:11 ddurieux

Thanks for the fast answer!

glpi-CORSerror

menemat avatar Nov 26 '19 08:11 menemat

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

ddurieux avatar Nov 26 '19 08:11 ddurieux

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?

menemat avatar Nov 26 '19 08:11 menemat

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

ddurieux avatar Nov 26 '19 08:11 ddurieux