FIX Implementation of a Luracast recommandation for the REST api server (#7370)

This commit is contained in:
Neil Orley 2017-09-19 16:56:27 +02:00
parent 949eef82f0
commit caf4ca7451

View File

@ -48,7 +48,7 @@ class DolibarrApi
*/
function __construct($db, $cachedir='', $refreshCache=false)
{
global $conf;
global $conf, $dolibarr_main_url_root;
if (empty($cachedir)) $cachedir = $conf->api->dir_temp;
Defaults::$cacheDirectory = $cachedir;
@ -57,6 +57,8 @@ class DolibarrApi
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
$this->r = new Restler($production_mode, $refreshCache);
$this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot);
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$this->r->setAPIVersion(1);
}