Skip to content

Commit 9330c6d

Browse files
fix(e2e): set front_controller_active so Nextcloud generates clean URLs
Without Apache/mod_rewrite, Nextcloud redirects /apps/libresign to /index.php/apps/libresign. The Vue Router then builds relative paths from /index.php/, causing URL duplication and a broken app state. PHP's built-in server reads the front_controller_active env variable (see lib/private/URLGenerator.php). When true, Nextcloud generates clean URLs without the index.php prefix — the same behavior that Apache's .htaccess RewriteRule provides — and our router.php already handles routing those clean URLs to index.php. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 1d5218a commit 9330c6d

3 files changed

Lines changed: 4 additions & 46 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,28 +188,13 @@ jobs:
188188
189189
- name: Start PHP built-in server
190190
run: |
191-
php -S localhost:8080 -t . apps/${{ env.APP_NAME }}/playwright/router.php &
191+
# front_controller_active tells Nextcloud to generate clean URLs (without index.php prefix)
192+
# This mirrors what Apache mod_rewrite does via .htaccess RewriteRule
193+
front_controller_active=true php -S localhost:8080 -t . apps/${{ env.APP_NAME }}/playwright/router.php &
192194
# Wait for server to become available
193195
timeout 30 bash -c 'until curl -s http://localhost:8080/status.php > /dev/null; do sleep 1; done'
194196
echo "Nextcloud is ready at http://localhost:8080"
195197
196-
- name: Debug - Check if build artifacts exist
197-
run: |
198-
echo "Checking for LibreSign JS build artifacts..."
199-
ls -lah apps/${{ env.APP_NAME }}/js/ || echo "js/ directory not found"
200-
echo "---"
201-
echo "Testing status endpoint:"
202-
curl -v http://localhost:8080/status.php
203-
echo "---"
204-
echo "Testing index endpoint:"
205-
curl -I http://localhost:8080/index.php
206-
echo "---"
207-
echo "Testing app endpoint (should load HTML with JS):"
208-
curl -s http://localhost:8080/apps/libresign | head -100
209-
echo "---"
210-
echo "Checking if app is enabled:"
211-
php occ app:list | grep libresign
212-
213198
- name: Install Playwright browsers
214199
working-directory: apps/${{ env.APP_NAME }}
215200
run: npx playwright install chromium --with-deps

playwright/e2e/sign-herself-with-click-to-sign.spec.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,7 @@ test('sign herself with click to sign', async ({ page }) => {
3232
]),
3333
)
3434

35-
// Capture console logs to debug
36-
page.on('console', msg => console.log('BROWSER CONSOLE:', msg.type(), msg.text()))
37-
38-
// Debug: log the URL being constructed before goto
39-
const testUrl = new URL('./apps/libresign', 'http://localhost:8080').toString()
40-
console.log('Test URL constructed:', testUrl)
41-
console.log('Page URL:', page.url())
42-
console.log('Page title:', await page.title())
43-
await page.screenshot({ path: 'debug-before-click.png', fullPage: true })
44-
const bodyHTML = await page.evaluate(() => document.body.innerHTML)
45-
console.log('Body HTML length:', bodyHTML.length)
46-
console.log('Body HTML preview:', bodyHTML.substring(0, 500))
47-
35+
await page.goto('./apps/libresign')
4836
await page.getByRole('button', { name: 'Upload from URL' }).click();
4937
await page.getByRole('textbox', { name: 'URL of a PDF file' }).fill('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf');
5038
await page.getByRole('button', { name: 'Send' }).click();

playwright/router.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
1717
$file = $rootDir . $uri;
1818

19-
// Debug: log all requests (to stderr so it shows in PHP output)
20-
error_log(sprintf(
21-
'[ROUTER] REQUEST_URI=%s | URI=%s | SCRIPT_NAME=%s | file_exists=%d',
22-
$_SERVER['REQUEST_URI'],
23-
$uri,
24-
$_SERVER['SCRIPT_NAME'] ?? 'N/A',
25-
file_exists($file) ? 1 : 0
26-
));
27-
2819
// Serve static files as-is (except PHP files)
2920
if ($uri !== '/' && file_exists($file) && !is_dir($file) && pathinfo($uri, PATHINFO_EXTENSION) !== 'php') {
3021
return false;
@@ -35,12 +26,6 @@
3526
$_SERVER['SCRIPT_FILENAME'] = $rootDir . $script;
3627
$_SERVER['PHP_SELF'] = $script;
3728
$_SERVER['PATH_INFO'] = substr($uri, strlen($script)) ?: '';
38-
error_log(sprintf(
39-
'[ROUTER DISPATCH] SCRIPT=%s | PATH_INFO=%s | SCRIPT_FILENAME=%s',
40-
$script,
41-
$_SERVER['PATH_INFO'] ?? 'empty',
42-
$_SERVER['SCRIPT_FILENAME']
43-
));
4429
require $rootDir . $script;
4530
};
4631

0 commit comments

Comments
 (0)