From a79de56d32c3a78f03a59ea2d9f8bdc3151082ce Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Tue, 12 Dec 2023 20:00:19 +0000 Subject: [PATCH] feat: authorise server --- .env.example | 3 ++- index.mjs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index e219aa3..5862588 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ MONGODB= -JWT_SECRET= \ No newline at end of file +JWT_SECRET= +SERVER_TOKEN= \ No newline at end of file diff --git a/index.mjs b/index.mjs index a9580b9..e42a9f9 100644 --- a/index.mjs +++ b/index.mjs @@ -47,6 +47,10 @@ app.get("/jwt", async (req, res) => { }); app.post("/info", async (req, res) => { + if (req.headers["x-server"] !== process.env.SERVER_TOKEN) { + return res.status(403).send("Not server."); + } + const token = req.headers["x-jwt"]; if (token) { try {