From 8a4063d44e0881d3c1132b1eed3cdc69b2217a74 Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 13 Jan 2026 09:09:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20merge=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/index.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index df302bd3..89c90381 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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": { diff --git a/backend/src/restful/index.js b/backend/src/restful/index.js index e0452abd..34505c07 100644 --- a/backend/src/restful/index.js +++ b/backend/src/restful/index.js @@ -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));