From f8a56aa61355761a2dbc22e611847d00f2affa15 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Sun, 3 Nov 2019 15:01:00 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=BF=E2=98=95=EF=B8=8F=20Checkpoint=20.?= =?UTF-8?q?/server.js:933874/11361?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 7d10f35..85af8b2 100644 --- a/server.js +++ b/server.js @@ -23,13 +23,19 @@ app.get("/", (req, res) => { // http://expressjs.com/en/starter/basic-routing.html app.get("/img", (req, res) => { - if (fuzIsOpen && Date() - (2 * 60 * 1000) < lastSeen) { + if (fuzIsOpen && new Date() - 2 * 60 * 1000 < lastSeen) { return res.sendFile(__dirname + "/views/open.svg"); } res.sendFile(__dirname + "/views/closed.svg"); }); app.get("/api", (req, res) => { - res.send(fuzIsOpen && new Date() - (2 * 60 * 1000) < lastSeen); + res.header("Access-Control-Allow-Origin", "*"); + res.header( + "Access-Control-Allow-Headers", + "Origin, X-Requested-With, Content-Type, Accept" + ); + res.send({ fuzIsOpen, lastSeen + }); }); // http://expressjs.com/en/starter/basic-routing.html