Skip to content

Commit 573a9c6

Browse files
authored
Fix webpack chunk loading with STATIC_URL_PREFIX (#11526) (#11542)
Previously, we had only set __webpack_public_path__ to a path which caused webpack chunks to be loaded from the current origin which is incorrect when STATIC_URL_PREFIX points to another origin. This should fix the issue curretnly seen on gitea.com.
1 parent d131d53 commit 573a9c6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

web_src/js/publicpath.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
// This sets up webpack's chunk loading to load resources from the 'public'
2-
// directory. This file must be imported before any lazy-loading is being attempted.
1+
// This sets up the URL prefix used in webpack's chunk loading.
2+
// This file must be imported before any lazy-loading is being attempted.
3+
const {StaticUrlPrefix} = window.config;
34

4-
if (document.currentScript && document.currentScript.src) {
5+
if (StaticUrlPrefix) {
6+
__webpack_public_path__ = StaticUrlPrefix.endsWith('/') ? StaticUrlPrefix : `${StaticUrlPrefix}/`;
7+
} else if (document.currentScript && document.currentScript.src) {
58
const url = new URL(document.currentScript.src);
69
__webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/');
710
} else {

0 commit comments

Comments
 (0)