diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index 125ee37de..875a23e25 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -88,7 +88,7 @@ class cron extends CI_Controller { echo "CRON: " . $cron->id . " -> is due: " . $isdue_result . "\n"; echo "CRON: " . $cron->id . " -> RUNNING...\n"; - $url = base_url() . $cron->function; + $url = local_url() . $cron->function; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 4c060a203..89e90b588 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -88,6 +88,28 @@ if ( ! function_exists('base_url')) } } +if ( ! function_exists('local_url')) +{ + /** + * Local URL + * + * For cornercases where you have no access to the base_url from + * within e.g. the docker container to the base_url use this url + * for cron jobs. + * + * If local_url is not defined return base_url instead. + * + * @param string $uri + * @param string $protocol + * @return string + */ + + function local_url($uri = '', $protocol = NULL) + { + return get_instance()->config->local_url($uri, $protocol) ?? get_instance()->config->base_url($uri, $protocol); + } +} + // ------------------------------------------------------------------------ if ( ! function_exists('current_url'))