Browse Source

added headers for CORS to work

Lucas 1 năm trước cách đây
mục cha
commit
42b81c9e87
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      index.js

+ 3 - 0
index.js

@@ -12,6 +12,7 @@ app.get("/api/text", (req, res) => {
       res.send(err);
       return;
     }
+    res.set("Access-Control-Allow-Origin", "*");
     res.send(data);
   });
 });
@@ -46,6 +47,7 @@ app.post("/api/add", (req, res) => {
 
     fs.writeFileSync("data.json", arrjson);
 
+    res.set("Access-Control-Allow-Origin", "*");
     res.send(text);
   });
 });
@@ -80,6 +82,7 @@ app.post("/api/remove", (req, res) => {
     fs.writeFileSync("data.json", arrjson);
   });
 
+  res.set("Access-Control-Allow-Origin", "*");
   res.send("Removed element at id: " + id);
 });