john 8 månader sedan
förälder
incheckning
2fda9657fb
2 ändrade filer med 8 tillägg och 16 borttagningar
  1. BIN
      .DS_Store
  2. 8 16
      node_expores/app.js

BIN
.DS_Store


+ 8 - 16
node_expores/app.js

@@ -41,22 +41,7 @@ function extractFileId(referer) {
 }
 
 // middleware that is specific to this router
-// 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) => {
+app.use(async function timeLog(req, res, next) {
   if (isValidReferer(req.url)) {
     const fileId = extractFileId(req.url);
     if (fileId) {
@@ -65,6 +50,13 @@ app.get("/", (req, res) => {
       console.error("File ID not found in referer");
     }
   }
+  next();
+});
+
+// 静态文件目录,添加前缀路径 /static
+app.use("/static", express.static("public"));
+
+app.get("/", (req, res) => {
   res.send("Hello World! " + req.url);
 });