浏览代码

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>
tags/v1.13.0-rc1
silverwind 4 年前
父节点
当前提交
b797b76abd
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9
    4
      web_src/js/publicpath.js

+ 9
- 4
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(/\/[^/]*?\/[^/]*?$/, '/');
}

正在加载...
取消
保存