yxk-20260721
bug修复,kk的在线预览报错:原因是生产环境前后端隔离,但是配置还是localhost
This commit is contained in:
+18
-1
@@ -58,6 +58,8 @@ public class FileController {
|
||||
private BaseCommonService baseCommonService;
|
||||
@Value(value = "${jeecg.appName}")
|
||||
private String applicationName;
|
||||
@Value(value = "${jeecg.file-preview-download-domain:}")
|
||||
private String filePreviewDownloadDomain;
|
||||
|
||||
private static final String FILE_PREVIEW_REDIS_PREFIX = "sys:file:preview:";
|
||||
private static final long FILE_PREVIEW_TOKEN_EXPIRE_SECONDS = 600L;
|
||||
@@ -619,7 +621,22 @@ public class FileController {
|
||||
|
||||
private String buildPreviewDownloadUrl(HttpServletRequest request, String token, String fileName) {
|
||||
// kkFileView judges the preview handler by file suffix; stream APIs without suffix need fullfilename.
|
||||
return buildRequestBaseUrl(request) + "/sys/file/previewDownload?token=" + token + "&fullfilename=" + encodeUrlParam(fileName);
|
||||
return getPreviewDownloadBaseUrl(request) + "/sys/file/previewDownload?token=" + token + "&fullfilename=" + encodeUrlParam(fileName);
|
||||
}
|
||||
|
||||
private String getPreviewDownloadBaseUrl(HttpServletRequest request) {
|
||||
if (!StringUtils.isEmpty(filePreviewDownloadDomain) && !StringUtils.isEmpty(filePreviewDownloadDomain.trim())) {
|
||||
// kkFileView may run on another host, so its download address must not depend on proxy headers.
|
||||
return trimTrailingSlash(filePreviewDownloadDomain.trim());
|
||||
}
|
||||
return buildRequestBaseUrl(request);
|
||||
}
|
||||
|
||||
private String trimTrailingSlash(String value) {
|
||||
while (value.endsWith("/")) {
|
||||
value = value.substring(0, value.length() - 1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private JSONObject parsePreviewInfo(Object cache) {
|
||||
|
||||
Reference in New Issue
Block a user