fix: 修复 merge 模式路由

This commit is contained in:
xream committed 2026-01-13 09:09:45 +08:00
1 parent 9ca21142cf
commit 8a4063d44e
2 files changed
+11 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.20.81",
"version": "2.20.82",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+10 -4
View File
@@ -93,13 +93,19 @@ export default function serve() {
}
}
}
if (be_merge && fe_path && req.path.indexOf('/', 1) == -1) {
if (req.path.indexOf('.') == -1) {
req.url = '/index.html';
}
const isBackendRoute = /^\/(api|download|share)(\/|$)/.test(
req.path,
);
if (be_merge && fe_path && !isBackendRoute) {
const express_ = eval(`require("express")`);
const mime_ = eval(`require("mime-types")`);
const path_ = eval(`require("path")`);
const fs_ = eval(`require("fs")`);
// 检查请求的文件是否真实存在,不存在则返回 index.html(SPA 路由)
const filePath = path_.join(fe_path, req.path);
if (!fs_.existsSync(filePath)) {
req.url = '/index.html';
}
const staticFileMiddleware = express_.static(fe_path, {
setHeaders: (res, path) => {
const type = mime_.contentType(path_.extname(path));