Skip to content

一分钟搭建影视站,支持Docker等部署方式

fix(server): 修复静态资源缓存导致配置不生效的问题

bestZweia87c44d8773f
diff --git a/js/config.js b/js/config.js
index 1538676..3dc5f81 100644
--- a/js/config.js
+++ b/js/config.js
@@ -43,7 +43,7 @@ window.FALLBACK_CORS_PROXY = FALLBACK_CORS_PROXY;
// 'builtin' = 内置 /proxy/(需后端已部署且已配置密码)
// 'cors' = 公共 CORS 代理(ciao-cors,任何部署环境可用)
// 'custom' = 用户自定义代理
-const IMAGE_PROXY_MODE = 'direct';
+const IMAGE_PROXY_MODE = 'builtin'; // 本地调试用:默认走内置代理避免豆瓣直连418;部署前请改回 'direct'(保持用户在设置中可选)
// 自定义代理模板:直接拼接编码后的图片地址,或写 {url} 占位符由系统替换
const CUSTOM_IMAGE_PROXY = '';
window.IMAGE_PROXY_MODE = localStorage.getItem('imageProxyMode') || IMAGE_PROXY_MODE;
diff --git a/server.mjs b/server.mjs
index c3a4d45..3ac7532 100644
--- a/server.mjs
+++ b/server.mjs
@@ -356,7 +356,13 @@ app.use((req, res, next) => {
});
app.use(express.static(path.join(__dirname), {
- maxAge: config.cacheMaxAge
+ maxAge: config.cacheMaxAge,
+ setHeaders: (res, filePath) => {
+ // 前端脚本/样式/页面不缓存,改动后刷新即生效(避免旧 config.js 缓存导致设置不生效)
+ if (/\.(js|mjs|css|html)$/.test(filePath)) {
+ res.setHeader('Cache-Control', 'no-cache');
+ }
+ }
}));
app.use((err, req, res, next) => {