From 061f50b714ebc4b3dfd55d55f54f54134c6ee84f Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 15 Oct 2022 21:51:45 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=82=D0=B4=D0=B0=D1=87=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D0=B8=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/utils.js | 5 +++++ server/index.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/core/utils.js b/server/core/utils.js index 07beff4..18b9535 100644 --- a/server/core/utils.js +++ b/server/core/utils.js @@ -108,6 +108,10 @@ function gzipFile(inputFile, outputFile, level = 1) { }); } +function toUnixPath(dir) { + return dir.replace(/\\/g, '/'); +} + module.exports = { sleep, versionText, @@ -120,4 +124,5 @@ module.exports = { intersectSet, randomHexString, gzipFile, + toUnixPath, }; \ No newline at end of file diff --git a/server/index.js b/server/index.js index 5eeb084..f6305d1 100644 --- a/server/index.js +++ b/server/index.js @@ -208,10 +208,10 @@ function initStatic(app, config) { const filesDir = `${config.publicDir}/files`; app.use(express.static(config.publicDir, { setHeaders: (res, filePath) => { - res.set('Cache-Control', 'no-cache'); - res.set('Expires', '-1'); + //res.set('Cache-Control', 'no-cache'); + //res.set('Expires', '-1'); - if (path.dirname(filePath) == filesDir) { + if (utils.toUnixPath(path.dirname(filePath)) == utils.toUnixPath(filesDir)) { res.set('Content-Encoding', 'gzip'); if (res.downFileName)