From: Benjamin Auder Date: Tue, 12 Mar 2019 16:36:02 +0000 (+0100) Subject: Remove test instructions, fix CORS for DELETE method X-Git-Url: https://git.auder.net/doc/html/css/img/current/gitweb.css?a=commitdiff_plain;h=77fd729819118d491ff91c1d99960add2ef9cff3;p=vchess.git Remove test instructions, fix CORS for DELETE method --- diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 1d842d5a..19f2e77d 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -125,10 +125,6 @@ export default { created: function() { // Always add myself to players' list this.players.push(this.st.user); - - console.log("created"); -ajax("/testtest", "DELETE"); - // Ask server for current corr games (all but mines) // ajax( // "", diff --git a/server/app.js b/server/app.js index d4aef286..13cf1dbf 100644 --- a/server/app.js +++ b/server/app.js @@ -36,8 +36,9 @@ if (params.cors.enable) app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", params.cors.allowedOrigin); res.header("Access-Control-Allow-Headers", - "Origin, X-Requested-With, Content-Type, Accept"); - next(); + "Origin, X-Requested-With, Content-Type, Accept"); + res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE"); + next(); }); } diff --git a/server/models/Challenge.js b/server/models/Challenge.js index 8adf3cac..de2818ba 100644 --- a/server/models/Challenge.js +++ b/server/models/Challenge.js @@ -126,15 +126,6 @@ const ChallengeModel = }); }, - testfunc: function() - { - db.serialize(function() { - db.run("DELETE * FROM TableTest", (err,ret) => { - console.log(ret); - }); - }); - }, - remove: function(id, uid) { db.serialize(function() { diff --git a/server/routes/challenges.js b/server/routes/challenges.js index 99f055fc..40c50ec8 100644 --- a/server/routes/challenges.js +++ b/server/routes/challenges.js @@ -5,11 +5,6 @@ const access = require("../utils/access"); const ChallengeModel = require("../models/Challenge"); const UserModel = require("../models/User"); //for name check -router.delete("/testtest", access.ajax, (req,res) => { - console.log("passag"); - ChallengeModel.testfunc(); -}); - router.post("/challenges", access.logged, access.ajax, (req,res) => { const error = ChallengeModel.checkChallenge(req.body.chall); if (!!error) @@ -70,7 +65,7 @@ router.post("/challenges", access.logged, access.ajax, (req,res) => { //} router.delete("/challenges", access.logged, access.ajax, (req,res) => { - const cid = req.query.cid; + const cid = req.query.id; ChallengeModel.remove(cid, req.userId, err => { res.json(err || {}); });