瀏覽代碼

Limit routes

Noah 9 年之前
父節點
當前提交
642cbecd3e
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      server/index.js

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

66
 // Serve background images and themes JSON statically
66
 // Serve background images and themes JSON statically
67
 app.use("/settings/", function(req, res, next) {
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
 }, express.static(path.join(__dirname, "..", "settings")));
76
 }, express.static(path.join(__dirname, "..", "settings")));
77
 
77