浏览代码

Limit routes

Noah 7 年前
父节点
当前提交
642cbecd3e
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      server/index.js

+ 4 - 4
server/index.js 查看文件

@@ -66,12 +66,12 @@ app.get("/status/:id/", status);
66 66
 // Serve background images and themes JSON statically
67 67
 app.use("/settings/", function(req, res, next) {
68 68
 
69
-  // Keep server settings off limits
70
-  if (req.url.match(/\.js$/i)) {
71
-    return res.status(404).send("Cannot GET " + path.join("/settings", req.url));
69
+  // Limit to themes.json and bg images
70
+  if (req.url.match(/^\/?themes.json$/i) || req.url.match(/^\/?backgrounds\/[^/]+$/i)) {
71
+    return next();
72 72
   }
73 73
 
74
-  next();
74
+  return res.status(404).send("Cannot GET " + path.join("/settings", req.url));
75 75
 
76 76
 }, express.static(path.join(__dirname, "..", "settings")));
77 77