Xibo 4.4.4 on Windows Apache generates malformed preview URLs causing widget previews to fail

Xibo 4.4.4 Widget Preview Failure on Windows Apache Due to Malformed Base URL Generation

I encountered an issue where widget previews in the Layout Designer consistently failed with:

“Sorry we could not find that page.”

This occurred on a completely fresh installation and affected widgets such as Analogue Clock and Digital Clock.

After extensive troubleshooting, the issue was traced to the URL generated for preview resources. The preview URL was being built incorrectly, resulting in failed requests to the preview subsystem.

Environment
Xibo CMS 4.4.4
Windows Server 2022 Datacenter
Apache 2.4.57 win64 VS16
PHP 8.1.29
MySQL 8.4
Manual (non-Docker) installation
CMS installed at the web root

**
Symptoms**

In Layout Designer:

Create a new layout.
Add a Clock widget (or other widget requiring preview rendering).
The widget does not render.
Designer shows:

“Sorry we could not find that page.”

Preview requests fail despite:

Valid layouts
Valid widgets
Working database
Working Apache rewrites
Valid JWT generation
Initial Investigation

The issue persisted after:

Fresh CMS installation
Fresh database
Fresh library folder
Regenerated keys
Restoring the stock .htaccess
Creating entirely new layouts and widgets

This ruled out:

Database corruption
Migration issues
Library corruption
Widget data corruption
Layout corruption
Rewrite rule ordering problems
Relevant URL Behavior

Preview URLs were being generated like:
http:////preview/playlist/widget/resource/{regionId}/{widgetId}

Notice the double slash:
//preview

Manually changing the URL to:
http:///preview/playlist/widget/resource/{regionId}/{widgetId}

allowed the widget preview to render correctly.

This proved that:

The preview endpoint works
The widget exists
The route exists
The JWT is valid
The issue is related to URL generation
Investigation Results

The preview URL is built in:
lib/Controller/Region.php

using:
$baseUrl = (new HttpsDetect())->getBaseUrl($request);

and later:
$baseUrl . ‘/preview/playlist/widget/resource/’ . $region->regionId . ‘/’ . $widget->widgetId

To determine what value was being returned, logging was added:
error_log(‘XIBO BASEURL=[’ . $baseUrl . ‘]’);

The log output showed:
XIBO BASEURL=[http://]

The generated base URL contained a trailing backslash, which appears to ultimately result in malformed preview URLs being generated.

Temporary Workaround

Replacing:
$baseUrl = (new HttpsDetect())->getBaseUrl($request);

with:
$baseUrl = rtrim(
str_replace(‘\’, ‘’, (new HttpsDetect())->getBaseUrl($request)),
‘/’
);

immediately resolved the issue.

After this change:

Widget previews rendered correctly
Clock widgets worked normally
Preview URLs were generated correctly
Layout Designer functionality was restored
Suspected Root Cause

The issue appears to originate from:
Xibo\Helper\HttpsDetect::getBaseUrl()

on Windows/Apache installations.

In this environment, the method appears to return a malformed URL containing a trailing backslash and/or an incorrectly normalized path, which causes invalid preview URLs to be generated.

Request

Could the Xibo team please review how HttpsDetect::getBaseUrl() generates URLs on Windows Apache deployments?

Specifically:

Should getBaseUrl() ever return a value containing a trailing backslash?
Is this a known issue on Windows installations?
Is there an official fix that should be applied instead of normalizing the URL in Region.php?

The workaround above fully restores preview functionality, but it would be great to determine the underlying cause and whether a core fix is appropriate.

Smae here,
Check it out how i solved:

Hey,
Thanks for sharing. unfortunately, I tried that fix, and it did not work for me.

The big issue was Preview URL was showing double slashes like, http:////preview/playlist/widget/resource/30/22?preview=1…
All widgets refused to load because of this Preview URL bug.