summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-05-21 00:33:31 +0200
committerGitHub <noreply@github.com>2020-05-20 23:33:31 +0100
commitb797b76abd13beba348415bdb81c7d3593bb01f9 (patch)
treeeddd72425980dd691ee65823b4f92fe21836e73b /web_src
parentc7c61778bcbda0f6bda7a6e942694df2593cc102 (diff)
downloadgitea-b797b76abd13beba348415bdb81c7d3593bb01f9.tar.gz
gitea-b797b76abd13beba348415bdb81c7d3593bb01f9.zip
Fix webpack chunk loading with STATIC_URL_PREFIX (#11526)
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. Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/publicpath.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/web_src/js/publicpath.js b/web_src/js/publicpath.js
index 892bb459aa..38865aa666 100644
--- a/web_src/js/publicpath.js
+++ b/web_src/js/publicpath.js
@@ -1,5 +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;
-const url = new URL(document.currentScript.src);
-__webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/');
+if (StaticUrlPrefix) {
+ __webpack_public_path__ = StaticUrlPrefix.endsWith('/') ? StaticUrlPrefix : `${StaticUrlPrefix}/`;
+} else {
+ const url = new URL(document.currentScript.src);
+ __webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/');
+}