Alerts Widget Links Fail

.Hi,

Just can’t quite find this in the code (any pointers appreciated) … but the URL / links for items in the Alerts table does not work if RewriteBase is not empty (i.e. if there is a path there, like /librenms). The other widgets are fine, but clicking on an item in the Alerts widget fails (again, if RewriteBase is used).

Thanks!

Set base_url

I checked, base_url is set also,

$config['base_url'] =(!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . 'librenms/';

Thoughts?

Thanks!

Feel free to change the link in question to use the url() helper and send a PR.

Will do! Just need to find where those dang widgets are at :laughing:. Will do some digging!

Working my way through - seems to be related to calling generate_url, thinking something is missing in the array passed over. In the process I also found that the links on the Ports page have the same issue :laughing:. And the Health pages!

I admit, struggline with all the redirects, function calling, etc. … :rofl:. I do think it’s in generate (url), inside of LibreNMS/Util/Url.php, but I may be wrong. It’s not adding in the RewriteBase.

    public static function generate($vars, $new_vars = [])
    {
        $vars = array_merge($vars, $new_vars);

        $url = url($vars['page'] . '');
        unset($vars['page']);

        return $url . self::urlParams($vars);
    }

Thanks!

UPDATE: OK, confirmed - if I change the $url to
$url = url('librenms/' . $vars['page'] . '');
Then it works … but not sure if I pull this from config.php or .htaccess. I admit, neither one seems quite right (nor available), but this is where the fix needs to be.

Figured it out! For generate_url => I’ll fix generate_link yet, then PR coming :smile:

But one debugging question, hoping for some guidance. Have tracked down the issue to public static function deviceUrl, trying to get some variable values => how to “see” them? Thanks!

Added PR#11937, addresses generate_url. Still trying to work through the device links, that seems to get into the depths of laravel (I think :wink:).

Thanks!