Skip to content

Commit

Permalink
Fix webpack chunk loading with STATIC_URL_PREFIX (go-gitea#11526) (go…
Browse files Browse the repository at this point in the history
…-gitea#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.
  • Loading branch information
silverwind authored May 22, 2020
1 parent d131d53 commit 573a9c6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions web_src/js/publicpath.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 573a9c6

Please sign in to comment.