]> source.dussan.org Git - gitea.git/commitdiff
Fix webpack chunk loading with STATIC_URL_PREFIX (#11526) (#11542)
authorsilverwind <me@silverwind.io>
Fri, 22 May 2020 19:18:44 +0000 (21:18 +0200)
committerGitHub <noreply@github.com>
Fri, 22 May 2020 19:18:44 +0000 (20:18 +0100)
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.

web_src/js/publicpath.js

index 392c03e7003c2c286871802fced9350776272484..0e69479b5cf7769744f54fffd7ce590062dfe18b 100644 (file)
@@ -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 {