Skip to content

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

修复反向代理后的客户端请求

Mr.Jos397b0d8399d9
diff --git a/server.mjs b/server.mjs
index bc72e5b..e7552b7 100644
--- a/server.mjs
+++ b/server.mjs
@@ -122,6 +122,13 @@ function isValidUrl(urlString) {
}
}
+// 修复反向代理处理过的路径
+app.use('/proxy', (req, res, next) => {
+ const targetUrl = req.url.replace(/^\//, '').replace(/(https?:)\/([^/])/, '$1//$2');
+ req.url = '/' + encodeURIComponent(targetUrl);
+ next();
+});
+
// 代理路由
app.get('/proxy/:encodedUrl', async (req, res) => {
try {