From fa485a77bfc8cba072bd09beec0b60756f8c9d11 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 1 Sep 2026 18:52:38 +0200 Subject: [PATCH] fix(router): resolve deep links in both URL forms Nextcloud serves an app under both /apps/decidiq/... and /index.php/apps/decidiq/..., but generateUrl() returns only the form the instance is configured for. Used as the vue-router base, that means a visitor arriving on the other form has a pathname the router cannot strip its base from. No route matches, the catch-all takes over, and they land on the dashboard with no error at all. Measured live on learniq, which had the identical base, across all 282 of its routes: /apps/learniq/courses resolved to Courses, and /index.php/apps/learniq/courses resolved to the dashboard. Not one broken page, every deep link in that URL form. routerBase() derives the base from the pathname, so it always matches the URL the visitor actually arrived on. openregister, opencatalogi, stackiq, larpinq, zaakafhandelapp, pipelinq and keepiq already do exactly this. --- src/main.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index a8e14d76d..b418e3e32 100644 --- a/src/main.js +++ b/src/main.js @@ -150,8 +150,35 @@ function routesFromManifest(manifest) { return routes } +/** + * The router base for THIS page load. + * + * ⚠️ `generateUrl('/apps/decidiq')` alone is not enough. Nextcloud serves the + * app under BOTH `/apps/decidiq/...` and `/index.php/apps/decidiq/...`, but + * `generateUrl()` returns only the form the instance is configured for. A + * visitor arriving on the other form — a bookmark, an emailed deep link, an + * integration that hardcodes `/index.php` — has a pathname the router cannot + * strip its base from. No route matches, the catch-all takes over, and they + * land on the dashboard with no error at all: the deep link is silently + * swallowed. + * + * Measured on a live instance for learniq, across all 282 of its routes: + * `/apps/learniq/courses` resolved to Courses, `/index.php/apps/learniq/courses` + * resolved to the dashboard. Every route behaved the same way, so this is not + * one broken page but every deep link in that URL form. + * + * Deriving the base from the pathname makes both forms resolve, because the + * base then always matches the URL the visitor actually arrived on. + * + * @return {string} The base path vue-router should strip from the URL. + */ +function routerBase() { + const match = window.location.pathname.match(/^(.*\/apps\/decidiq)(?:\/|$)/) + return match ? match[1] : generateUrl('/apps/decidiq') +} + const router = createRouter({ - history: createWebHistory(generateUrl('/apps/decidiq')), + history: createWebHistory(routerBase()), routes: routesFromManifest(mergedManifest), })