Исправлена отдача статики под Windows
This commit is contained in:
@@ -108,6 +108,10 @@ function gzipFile(inputFile, outputFile, level = 1) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toUnixPath(dir) {
|
||||||
|
return dir.replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sleep,
|
sleep,
|
||||||
versionText,
|
versionText,
|
||||||
@@ -120,4 +124,5 @@ module.exports = {
|
|||||||
intersectSet,
|
intersectSet,
|
||||||
randomHexString,
|
randomHexString,
|
||||||
gzipFile,
|
gzipFile,
|
||||||
|
toUnixPath,
|
||||||
};
|
};
|
||||||
@@ -208,10 +208,10 @@ function initStatic(app, config) {
|
|||||||
const filesDir = `${config.publicDir}/files`;
|
const filesDir = `${config.publicDir}/files`;
|
||||||
app.use(express.static(config.publicDir, {
|
app.use(express.static(config.publicDir, {
|
||||||
setHeaders: (res, filePath) => {
|
setHeaders: (res, filePath) => {
|
||||||
res.set('Cache-Control', 'no-cache');
|
//res.set('Cache-Control', 'no-cache');
|
||||||
res.set('Expires', '-1');
|
//res.set('Expires', '-1');
|
||||||
|
|
||||||
if (path.dirname(filePath) == filesDir) {
|
if (utils.toUnixPath(path.dirname(filePath)) == utils.toUnixPath(filesDir)) {
|
||||||
res.set('Content-Encoding', 'gzip');
|
res.set('Content-Encoding', 'gzip');
|
||||||
|
|
||||||
if (res.downFileName)
|
if (res.downFileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user