ExAppUiMiddleware drops the Nextcloud webroot when rewriting JavaScript and CSS proxy URLs
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Start in lib/Middleware/ExAppUiMiddleware.php, in beforeOutput(), where the JavaScript and CSS sections rewrite proxy URLs with regular expressions. The issue suggests building them with the URL generator and the route 'app_api.ExAppProxy.ExAppGet'. Reproduce with overwritewebroot set to /cloud and check that the generated URLs keep that prefix. Done when both resource types load under a subdirectory install.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
ExAppUiMiddleware::beforeOutput() generates incorrect proxy URLs for JavaScript and CSS resources registered through the AppAPI TopMenu mechanism when Nextcloud is installed in a subdirectory.
The current implementation uses regular-expression-based URL rewriting to construct proxy URLs manually.
In both cases, the configured Nextcloud webroot (e.g. /cloud, configured through overwritewebroot) is lost during URL rewriting.
As a result, the generated URLs point to the wrong location and the corresponding ExApp resources cannot be loaded correctly.
We reproduced this issue independently for both JavaScript and CSS resources using a custom Nextcloud External App.
Both problems could be fixed locally by using Nextcloud's IURLGenerator::linkToRoute() instead of manually constructing the URLs.
Steps/Code to Reproduce
Install Nextcloud in a subdirectory, for example /cloud.
Configure the webroot:
'overwritewebroot' => '/cloud',
'overwrite.cli.url' => 'https://example.com/cloud',
Install and configure AppAPI.
Create an External App (e.g. exapp_test) and register a JavaScript resource through the AppAPI TopMenu mechanism.
Open the corresponding TopMenu entry in Nextcloud.
Inspect the generated JavaScript URL in the browser's Network tab.
Additionally, register a CSS resource through the same TopMenu mechanism and inspect its generated URL.
Both resources are processed by ExAppUiMiddleware::beforeOutput() in lib/Middleware/ExAppUiMiddleware.php.
JavaScript example:
Original URL:
/cloud/index.php/apps/app_api/proxy/exapp_test/js/main.js
Generated URL:
/index.php/apps/app_api/proxy/exapp_test/js/main.js
CSS example:
The original CSS proxy URL contains the configured /cloud webroot. The existing regular-expression replacement removes this prefix when generating the final proxy URL.
The issue was reproduced using a separately registered test stylesheet (main.css) in our custom Test External App.
Expected Results
The generated proxy URLs should preserve the configured Nextcloud webroot.
For example:
JavaScript:
/cloud/index.php/apps/app_api/proxy/exapp_test/js/main.js
CSS:
/cloud/index.php/apps/app_api/proxy//.css
Both resources should load successfully when Nextcloud is installed in a subdirectory.
Actual Results
The original implementation removes the configured webroot during URL rewriting.
For example, a JavaScript URL beginning with:
/cloud/index.php/apps/app_api/proxy/exapp_test/js/main.js
is rewritten to:
/index.php/apps/app_api/proxy/exapp_test/js/main.js
The /cloud prefix is missing.
The CSS rewriting code uses a similar manual URL transformation and exhibits the same problem.
Consequently, the browser requests URLs outside the actual Nextcloud installation path. The resources cannot be loaded correctly.
We independently reproduced both problems with registered TopMenu resources.
Proposed solution:
We replaced the manual URL construction in both the CSS and JavaScript rewriting sections of ExAppUiMiddleware::beforeOutput() with Nextcloud's own URL generator:
$this->urlGenerator->linkToRoute(
'app_api.ExAppProxy.ExAppGet',
[
'appId' => $parts[0],
'other' => $parts[1],
]
);
For JavaScript resources, the .js extension is appended to the resource path as required.
This approach delegates URL generation to Nextcloud and correctly respects the configured webroot.
Verification:
The modified middleware was installed and tested successfully.
Both JavaScript and CSS resources registered through AppAPI TopMenu now load correctly with Nextcloud installed under /cloud.
The complete modified ExAppUiMiddleware.php is available, and we can provide the corresponding patch/diff if required.
Setup configuration
Nextcloud: 34.0.2
AppAPI: 34.0.0
Installation type: Subdirectory installation
Nextcloud webroot: /cloud
overwritewebroot: /cloud
Reverse proxy: Apache2
External App: Custom Gambas-based ExApp
Browser: Tested using browser developer tools (Network tab)
- Ngôn ngữ chính
- PHP
- Star
- 202
- Fork
- 30
- Merge trung bình
- 3 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/app_api
-
bug docker
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Daemon delete dialog: "Remove all ExApps" checkbox and `removeExApps` parameter have no effectĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Meta ex-app updates issueĐang mởdeploy discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
nextcloud/app_api#1236 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
deploy docker enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug deploy docker
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/app_api
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
enhancement priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
magicsunday/webtrees-statistics#664 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày