aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-05-22 21:18:44 +0200
committerGitHub <noreply@github.com>2020-05-22 20:18:44 +0100
commit573a9c62281c31da71adc36c70b2d50de5fd73c2 (patch)
treee17b95810194d57176b9d0d90fa97493a6d38589 /web_src/js
parentd131d53cbb84c3710e4f4138487a81a079a19f2b (diff)
downloadgitea-573a9c62281c31da71adc36c70b2d50de5fd73c2.tar.gz
gitea-573a9c62281c31da71adc36c70b2d50de5fd73c2.zip
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.
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/publicpath.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/web_src/js/publicpath.js b/web_src/js/publicpath.js
index 392c03e700..0e69479b5c 100644
--- a/web_src/js/publicpath.js
+++ b/web_src/js/publicpath.js
@@ -1,7 +1,10 @@
-// This sets up webpack's chunk loading to load resources from the 'public'
-// directory. This file must be imported before any lazy-loading is being attempted.
+// This sets up the URL prefix used in webpack's chunk loading.
+// This file must be imported before any lazy-loading is being attempted.
+const {StaticUrlPrefix} = window.config;
-if (document.currentScript && document.currentScript.src) {
+if (StaticUrlPrefix) {
+ __webpack_public_path__ = StaticUrlPrefix.endsWith('/') ? StaticUrlPrefix : `${StaticUrlPrefix}/`;
+} else if (document.currentScript && document.currentScript.src) {
const url = new URL(document.currentScript.src);
__webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/');
} else {