|
@@ -30,36 +30,42 @@ app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
// Helper function to validate referer
|
|
|
function isValidReferer(referer) {
|
|
|
return (
|
|
|
- referer.indexOf("zs_interval") > -1 && referer.indexOf("/api/v1/files") > -1
|
|
|
+ referer.indexOf("zs_interval") > -1 && referer.indexOf("/api/v1/files") > -1 || referer.indexOf('api_files_') > -1
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// Helper function to extract `file_id` from referer
|
|
|
function extractFileId(referer) {
|
|
|
- const match = referer.match(/\/api\/v1\/files\/([^/]+)/); // 正则匹配 `file_id`
|
|
|
+ const match = referer.match(/api_files_([^/]+)/); // 正则匹配 `file_id`
|
|
|
return match ? match[1] : null;
|
|
|
}
|
|
|
|
|
|
// middleware that is specific to this router
|
|
|
-app.use(async function timeLog(req, res, next) {
|
|
|
- console.log(45, req.url);
|
|
|
+// app.use(async function timeLog(req, res, next) {
|
|
|
+// if (isValidReferer(req.url)) {
|
|
|
+// const fileId = extractFileId(req.url);
|
|
|
+// if (fileId) {
|
|
|
+// return res.redirect(`/api/v1/files/${fileId}`);
|
|
|
+// } else {
|
|
|
+// console.error("File ID not found in referer");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// next();
|
|
|
+// });
|
|
|
+
|
|
|
+// 静态文件目录,添加前缀路径 /static
|
|
|
+app.use("/static", express.static("public"));
|
|
|
+
|
|
|
+app.get("/", (req, res) => {
|
|
|
if (isValidReferer(req.url)) {
|
|
|
const fileId = extractFileId(req.url);
|
|
|
- console.log(47, fileId);
|
|
|
if (fileId) {
|
|
|
return res.redirect(`/api/v1/files/${fileId}`);
|
|
|
} else {
|
|
|
console.error("File ID not found in referer");
|
|
|
}
|
|
|
}
|
|
|
- next();
|
|
|
-});
|
|
|
-
|
|
|
-// 静态文件目录,添加前缀路径 /static
|
|
|
-app.use("/static", express.static("public"));
|
|
|
-
|
|
|
-app.get("/", (req, res) => {
|
|
|
- res.send("Hello World!");
|
|
|
+ res.send("Hello World! " + req.url);
|
|
|
});
|
|
|
|
|
|
app.use("/api/v1/login", authors);
|