can setup web api url to use PATH_INFO

This commit is contained in:
maxpozdeev 2023-03-24 18:51:46 +03:00
parent a41eae1ea7
commit ced75b805a
4 changed files with 12 additions and 3 deletions

View file

@ -17,3 +17,7 @@ else if (getenv('MTT_DB_TYPE') == 'sqlite') {
}
define("MTT_SALT", "Put Random Text Here");
//define("MTT_DISABLE_EXT", 1);
if (getenv('MTT_API_USE_PATH_INFO')) {
define("MTT_API_USE_PATH_INFO", 1);
}

View file

@ -14,7 +14,7 @@ class ApiRequest
public $jsonBody;
function __construct() {
if (defined('MTT_API_USE_PATH_INFO') && MTT_API_USE_PATH_INFO) {
if (defined('MTT_API_USE_PATH_INFO')) {
$this->path = $_SERVER['PATH_INFO'];
}
else {

View file

@ -79,7 +79,7 @@ function js_options()
"lang" => Lang::instance()->jsStrings(),
"mttUrl" => get_mttinfo('mtt_url'),
"homeUrl" => get_mttinfo('url'),
// "apiUrl" => get_mttinfo('api_url'),
"apiUrl" => get_mttinfo('api_url'),
"needAuth" => need_auth() ? true : false,
"isLogged" => is_logged() ? true : false,
"showdate" => Config::get('showdate') ? true : false,

View file

@ -352,7 +352,12 @@ function get_unsafe_mttinfo($v)
/* URL for API, like http://localhost/mytinytodo/api/. No need to set by default. */
$_mttinfo['api_url'] = Config::getUrl('api_url'); // need to have a trailing slash
if ($_mttinfo['api_url'] == '') {
$_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/';
if (defined('MTT_API_USE_PATH_INFO')) {
$_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api/';
}
else {
$_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/';
}
}
return $_mttinfo['api_url'];
case 'title':